Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: tools/json_comment_eater/json_comment_eater.py

Issue 2797253011: Improve json_comment_eater.py performance. (Closed)
Patch Set: Improve JSON comment eater performance. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_comment_eater/json_comment_eater.py
diff --git a/tools/json_comment_eater/json_comment_eater.py b/tools/json_comment_eater/json_comment_eater.py
index d61ece20e26ba8c8516bc223908a74e7b498f0c6..17a15254f4b42d80f9f8814ae02eebd591f8b904 100755
--- a/tools/json_comment_eater/json_comment_eater.py
+++ b/tools/json_comment_eater/json_comment_eater.py
@@ -21,13 +21,12 @@ def _FindNextToken(string, tokens, start):
'''Finds the next token in |tokens| that occurs in |string| from |start|.
Returns a tuple (index, token key).
'''
- min_index, min_key = (-1, None)
- for k in tokens:
- index = string.find(k, start)
- if index != -1 and (min_index == -1 or index < min_index):
- min_index, min_key = (index, k)
- return (min_index, min_key)
+ for index, item in enumerate(string, start):
+ for k in tokens:
+ if (string[index:index + len(k)] == k):
+ return (index, k)
+ return (-1, None)
def _ReadString(input, start, output):
output.append('"')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698