feat: optimize unpacking properties in ServiceInfo (#1225) · python-zeroconf/python-zeroconf@1492e41

Original file line numberDiff line numberDiff line change

@@ -361,20 +361,11 @@ def _unpack_text_into_properties(self) -> None:

361361

strs.append(text[index : index + length])

362362

index += length

363363
364-

key: bytes

365-

value: Optional[bytes]

366364

for s in strs:

367-

key_value = s.split(b'=', 1)

368-

if len(key_value) == 2:

369-

key, value = key_value

370-

else:

371-

# No equals sign at all

372-

key = s

373-

value = None

374-
365+

key, _, value = s.partition(b'=')

375366

# Only update non-existent properties

376367

if key and key not in result:

377-

result[key] = value

368+

result[key] = value or None

378369
379370

# Properties should be set atomically

380371

# in case another thread is reading them