mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 20:22:03 +03:00
cache dataclass_fields lookup in merge_geo
This commit is contained in:
parent
329ff15e74
commit
ab39922bf6
1 changed files with 2 additions and 1 deletions
|
|
@ -176,8 +176,9 @@ _MERGE_SKIP = {"sources", "ip_type"}
|
||||||
def merge_geo(candidates: list[tuple[str, IpGeo]]) -> IpGeo:
|
def merge_geo(candidates: list[tuple[str, IpGeo]]) -> IpGeo:
|
||||||
merged = IpGeo()
|
merged = IpGeo()
|
||||||
sources: dict[str, str] = {}
|
sources: dict[str, str] = {}
|
||||||
|
fields = dataclass_fields(IpGeo)
|
||||||
for name, geo in candidates:
|
for name, geo in candidates:
|
||||||
for f in dataclass_fields(IpGeo):
|
for f in fields:
|
||||||
if f.name in _MERGE_SKIP:
|
if f.name in _MERGE_SKIP:
|
||||||
continue
|
continue
|
||||||
if getattr(merged, f.name) is not None:
|
if getattr(merged, f.name) is not None:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue