Skip to content

Commit 2576f49

Browse files
Lash-LCopilot
andauthored
chore: update roborock/protocol.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 46bceb2 commit 2576f49

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

roborock/protocol.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,11 @@ def _parse(self, stream, context, path):
351351
data = stream.read()
352352

353353
start_index = -1
354-
# Find the earliest occurrence of any valid version
355-
candidates = [idx for v in valid_versions if (idx := data.find(v)) != -1]
356-
if candidates:
357-
start_index = min(candidates)
354+
# Find the earliest occurrence of any valid version in a single pass
355+
for i in range(len(data) - 2):
356+
if data[i:i+3] in valid_versions:
357+
start_index = i
358+
break
358359

359360
if start_index != -1:
360361
# Found a valid version header at `start_index`.

0 commit comments

Comments
 (0)