Get a value representative of a mutable field to detect changes
(self, fld, val, copy=False)
| 681 | for fname, fval in fields.items()} |
| 682 | |
| 683 | def _raw_packet_cache_field_value(self, fld, val, copy=False): |
| 684 | # type: (AnyField, Any, bool) -> Optional[Any] |
| 685 | """Get a value representative of a mutable field to detect changes""" |
| 686 | _cpy = lambda x: fld.do_copy(x) if copy else x # type: Callable[[Any], Any] |
| 687 | if fld.holds_packets: |
| 688 | # avoid copying whole packets (perf: #GH3894) |
| 689 | if fld.islist: |
| 690 | return [ |
| 691 | (_cpy(x.fields), x.payload.raw_packet_cache) for x in val |
| 692 | ] |
| 693 | else: |
| 694 | return (_cpy(val.fields), val.payload.raw_packet_cache) |
| 695 | elif fld.islist or fld.ismutable: |
| 696 | return _cpy(val) |
| 697 | return None |
| 698 | |
| 699 | def clear_cache(self): |
| 700 | # type: () -> None |
no test coverage detected