X Tutup
Skip to content

Commit 8afe3a3

Browse files
committed
Do not create lists if not neede
1 parent bfa1327 commit 8afe3a3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bpython/line.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def current_word(cursor_offset, line):
2929
"""the object.attribute.attribute just before or under the cursor"""
3030
pos = cursor_offset
31-
matches = list(current_word_re.finditer(line))
31+
matches = current_word_re.finditer(line)
3232
start = pos
3333
end = pos
3434
word = None
@@ -43,15 +43,15 @@ def current_word(cursor_offset, line):
4343

4444
def current_dict_key(cursor_offset, line):
4545
"""If in dictionary completion, return the current key"""
46-
matches = list(current_dict_key_re.finditer(line))
46+
matches = current_dict_key_re.finditer(line)
4747
for m in matches:
4848
if m.start(1) <= cursor_offset and m.end(1) >= cursor_offset:
4949
return (m.start(1), m.end(1), m.group(1))
5050
return None
5151

5252
def current_dict(cursor_offset, line):
5353
"""If in dictionary completion, return the dict that should be used"""
54-
matches = list(current_dict_re.finditer(line))
54+
matches = current_dict_re.finditer(line)
5555
for m in matches:
5656
if m.start(2) <= cursor_offset and m.end(2) >= cursor_offset:
5757
return (m.start(1), m.end(1), m.group(1))
@@ -73,7 +73,7 @@ def current_object(cursor_offset, line):
7373
match = current_word(cursor_offset, line)
7474
if match is None: return None
7575
start, end, word = match
76-
matches = list(current_object_re.finditer(word))
76+
matches = current_object_re.finditer(word)
7777
s = ''
7878
for m in matches:
7979
if m.end(1) + start < cursor_offset:
@@ -105,7 +105,7 @@ def current_from_import_from(cursor_offset, line):
105105
tokens = line.split()
106106
if not ('from' in tokens or 'import' in tokens):
107107
return None
108-
matches = list(current_from_import_from_re.finditer(line))
108+
matches = current_from_import_from_re.finditer(line)
109109
for m in matches:
110110
if ((m.start(1) < cursor_offset and m.end(1) >= cursor_offset) or
111111
(m.start(2) < cursor_offset and m.end(2) >= cursor_offset)):

0 commit comments

Comments
 (0)
X Tutup