Skip to content

Commit 6005b72

Browse files
committed
Replace a loop with an rfind
1 parent f8ce916 commit 6005b72

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

bpython/autocomplete.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,10 @@ def matches(
398398

399399
assert "." in r.word
400400

401-
for i in range(1, len(r.word) + 1):
402-
if r.word[-i] == "[":
403-
i -= 1
404-
break
405-
methodtext = r.word[-i:]
401+
i = r.word.rfind("[") + 1
402+
methodtext = r.word[i:]
406403
matches = {
407-
"".join([r.word[:-i], m])
404+
"".join([r.word[:i], m])
408405
for m in self.attr_matches(methodtext, locals_)
409406
}
410407

0 commit comments

Comments
 (0)