summaryrefslogtreecommitdiffstats
path: root/tools/resources
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-11 23:19:17 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-11 23:19:17 +0000
commitfd061c5de83c3d68869934d12635a4ae3d48de25 (patch)
treeed3a12205d22c9e0dbd008368390ccb3dc08a56e /tools/resources
parentadc134bd9a8523621402e8c293da6805ef003772 (diff)
downloadchromium_src-fd061c5de83c3d68869934d12635a4ae3d48de25.zip
chromium_src-fd061c5de83c3d68869934d12635a4ae3d48de25.tar.gz
chromium_src-fd061c5de83c3d68869934d12635a4ae3d48de25.tar.bz2
Small optimization to find_unused_resources.py.
NOTRY=true Review URL: https://codereview.chromium.org/134783002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/resources')
-rwxr-xr-xtools/resources/find_unused_resources.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/resources/find_unused_resources.py b/tools/resources/find_unused_resources.py
index dfd1bba..d6e52c8 100755
--- a/tools/resources/find_unused_resources.py
+++ b/tools/resources/find_unused_resources.py
@@ -98,18 +98,28 @@ def GetUnusedResources(grd_filepath):
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: