Skip to content

Commit 157185f

Browse files
authored
feat: small performance improvement constructing outgoing questions (#1340)
1 parent 6560fad commit 157185f

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/zeroconf/_protocol/outgoing.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ cdef class DNSOutgoing:
127127
)
128128
cpdef packets(self)
129129

130-
cpdef add_question_or_all_cache(self, DNSCache cache, object now, str name, object type_, object class_)
130+
cpdef add_question_or_all_cache(self, DNSCache cache, double now, str name, object type_, object class_)
131131

132-
cpdef add_question_or_one_cache(self, DNSCache cache, object now, str name, object type_, object class_)
132+
cpdef add_question_or_one_cache(self, DNSCache cache, double now, str name, object type_, object class_)
133133

134134
cpdef add_question(self, DNSQuestion question)
135135

136136
cpdef add_answer(self, DNSIncoming inp, DNSRecord record)
137137

138138
@cython.locals(now_double=double)
139-
cpdef add_answer_at_time(self, DNSRecord record, object now)
139+
cpdef add_answer_at_time(self, DNSRecord record, double now)
140140

141141
cpdef add_authorative_answer(self, DNSPointer record)
142142

src/zeroconf/_protocol/outgoing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def add_question(self, record: DNSQuestion) -> None:
148148
def add_answer(self, inp: DNSIncoming, record: DNSRecord) -> None:
149149
"""Adds an answer"""
150150
if not record.suppressed_by(inp):
151-
self.add_answer_at_time(record, 0)
151+
self.add_answer_at_time(record, 0.0)
152152

153-
def add_answer_at_time(self, record: Optional[DNSRecord], now: Union[float, int]) -> None:
153+
def add_answer_at_time(self, record: Optional[DNSRecord], now: float_) -> None:
154154
"""Adds an answer if it does not expire by a certain time"""
155155
now_double = now
156156
if record is not None and (now_double == 0 or not record.is_expired(now_double)):

0 commit comments

Comments
 (0)