Skip to content

Commit 776e36f

Browse files
authored
Merge pull request #9 from GhostTypes/perf-optimize-discovery-string-concat-9065868647554307597
⚡ Optimize string concatenation in discovery debug output
2 parents d113534 + afab599 commit 776e36f

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

flashforge/discovery/discovery.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,26 +276,26 @@ def print_debug_info(self, response: bytes, ip_address: str) -> None:
276276
# Hex dump
277277
print("Hex dump:")
278278
for i in range(0, len(response), 16):
279-
line = f"{i:04x} "
279+
parts = [f"{i:04x} "]
280280

281281
# Hex values
282282
for j in range(16):
283283
if i + j < len(response):
284-
line += f"{response[i + j]:02x} "
284+
parts.append(f"{response[i + j]:02x} ")
285285
else:
286-
line += " "
286+
parts.append(" ")
287287

288288
if j == 7:
289-
line += " "
289+
parts.append(" ")
290290

291291
# ASCII representation
292-
line += " "
292+
parts.append(" ")
293293
for j in range(16):
294294
if i + j < len(response):
295295
c = response[i + j]
296-
line += chr(c) if 32 <= c <= 126 else '.'
296+
parts.append(chr(c) if 32 <= c <= 126 else '.')
297297

298-
print(line)
298+
print("".join(parts))
299299

300300
# ASCII dump
301301
print("ASCII dump:")

0 commit comments

Comments
 (0)