[gn build] sync script: try to make a loop clearer
We want to find 'sources = [', but only if it's not the prefix
of 'sources = []' -- we're looking for a non-empty list.
No behavior change.
diff --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
index 5c96fd7..912cf37 100755
--- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py
+++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
@@ -29,8 +29,7 @@
if add:
srcs_tok = 'sources = ['
tokloc = gn_contents.find(srcs_tok)
- while tokloc != -1 and tokloc + len(srcs_tok) < len(gn_contents) and \
- gn_contents[tokloc + len(srcs_tok)] == ']':
+ while gn_contents[tokloc:].startswith('sources = []'):
tokloc = gn_contents.find(srcs_tok, tokloc + 1)
if tokloc == -1: raise ValueError(gn_file + ': No source list')
if gn_contents.find(srcs_tok, tokloc + 1) != -1: