subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r932715 - /subversion/trunk/tools/dev/wc-ng/count-progress.py
Date Sat, 10 Apr 2010 12:58:24 GMT
Author: gstein
Date: Sat Apr 10 12:58:23 2010
New Revision: 932715

URL: http://svn.apache.org/viewvc?rev=932715&view=rev
Log:
Minor obvious speed-up.

* tools/dev/wc-ng/count-proress.py:
  (count_terms_in): read the files *once*, and then count each term found
    within the file.

Modified:
    subversion/trunk/tools/dev/wc-ng/count-progress.py

Modified: subversion/trunk/tools/dev/wc-ng/count-progress.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/wc-ng/count-progress.py?rev=932715&r1=932714&r2=932715&view=diff
==============================================================================
--- subversion/trunk/tools/dev/wc-ng/count-progress.py (original)
+++ subversion/trunk/tools/dev/wc-ng/count-progress.py Sat Apr 10 12:58:23 2010
@@ -52,8 +52,10 @@ def count_terms_in(path):
   counts = {}
   for term in TERMS:
     counts[term] = 0
-    for filepath in get_files_in(path):
-      counts[term] += open(filepath).read().count(term)
+  for filepath in get_files_in(path):
+    contents = open(filepath).read()
+    for term in TERMS:
+      counts[term] += contents.count(term)
   return counts
 
 



Mime
View raw message