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

Unified Diff: tools/resources/find_unused_resources.py

Issue 134783002: Small optimization to find_unused_resources.py. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 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/resources/find_unused_resources.py
===================================================================
--- tools/resources/find_unused_resources.py (revision 244227)
+++ tools/resources/find_unused_resources.py (working copy)
@@ -98,18 +98,28 @@
re.VERBOSE)
# Use finditer over the file contents because there may be newlines between
# the name and file attributes.
+ searched = set()
for result in pattern.finditer(grd_data):
# Extract the IDR resource id and file path.
resource_id = result.group(1)
filepath = result.group(2)
filename = os.path.basename(filepath)
+ base_resource_id = GetBaseResourceId(resource_id)
+
+ # Do not bother repeating searches.
+ key = (base_resource_id, filename)
+ if key in searched:
+ continue
+ searched.add(key)
+
# Print progress as we go along.
print resource_id
+
# Ensure the resource isn't used anywhere by checking both for the resource
# id (which should appear in C++ code) and the raw filename (in case the
# file is referenced in a script, test HTML file, etc.).
- base_resource_id = GetBaseResourceId(resource_id)
matching_files = FindFilesWithContents(base_resource_id, filename)
+
# Each file is matched once in the resource file itself. If there are no
# other matching files, it is unused.
if len(matching_files) == 1:
« 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