Skip to content

Commit 59eff27

Browse files
committed
improve gutter marks performance
1 parent 147842d commit 59eff27

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

Support/main.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def quiet():
123123
warning_count = 0
124124

125125
for issue in issues:
126-
if (should_ignore(issue['reason'])):
126+
if should_ignore(issue['reason']):
127127
continue
128128
if issue['isError']:
129129
error_count += 1
@@ -152,7 +152,7 @@ def update_gutter_marks(issues):
152152
marks = []
153153

154154
for item in issues:
155-
if (should_ignore(item['reason'])):
155+
if should_ignore(item['reason']):
156156
continue
157157
msg = item['reason']
158158
if 'shortname' in item:
@@ -162,15 +162,24 @@ def update_gutter_marks(issues):
162162

163163
subprocess.call([mate, '--clear-mark=warning', file_path])
164164

165-
for mark in marks:
166-
subprocess.call(
167-
[
168-
mate,
169-
'--set-mark=warning:[ESLint] {0}'.format(mark[0]),
170-
'--line={0}'.format(mark[1]),
171-
file_path
172-
]
173-
)
165+
# set the gutter marks 10 at a time to improve performance
166+
# the choice of 10 is arbitrary -- enough to improve performance
167+
# but shouldn’t cause the cmd line to be too long
168+
169+
def chunks(list_to_chunk, chunk_size):
170+
"""
171+
Yield successive chunk_size-sized chunks from list_to_chunk.
172+
"""
173+
for i in xrange(0, len(list_to_chunk), chunk_size):
174+
yield list_to_chunk[i:i + chunk_size]
175+
176+
for chunk in list(chunks(marks, 10)):
177+
args = [mate]
178+
for mark in chunk:
179+
args.append('--set-mark=warning:[ESLint] {0}'.format(mark[0]))
180+
args.append('--line={0}'.format(mark[1]))
181+
args.append(file_path)
182+
subprocess.call(args)
174183

175184

176185
def fix():

0 commit comments

Comments
 (0)