bug 1361037, don't cache en-US reference, r=flod
authorAxel Hecht <axel@pike.org>
Mon, 01 May 2017 21:15:44 +0200
changeset 220 c6f6afe9a93898d66606889d5aa1a42aa580240d
parent 219 402b3a8246cdc5c53a887379d252c22b099a7d62
child 221 fdca6dbd1a5f0b3d763afd04547a9c6d5842b47d
push id47
push useraxel@mozilla.com
push dateFri, 19 May 2017 17:46:33 +0000
reviewersflod
bugs1361037
bug 1361037, don't cache en-US reference, r=flod Most of the time, we just run one locale at a time. Then caching en-US doesn't help at all. Testing shows that even if we run multiple locales, this doesn't win us much. Subtle, but this is a shift from running compare-locales for one project against a lot of locales, towards run all projects against a single locale. Which will happen later in this patch queue. MozReview-Commit-ID: H61bItYOVQS
compare_locales/compare.py
--- a/compare_locales/compare.py
+++ b/compare_locales/compare.py
@@ -363,17 +363,16 @@ class ContentComparer:
     nl = re.compile('\n', re.M)
 
     def __init__(self):
         '''Create a ContentComparer.
         observer is usually a instance of Observer. The return values
         of the notify method are used to control the handling of missing
         entities.
         '''
-        self.reference = dict()
         self.observer = Observer()
         self.other_observers = []
         self.merge_stage = None
 
     def add_observer(self, obs):
         '''Add a non-filtering observer.
         Results from the notify calls are ignored.
         '''
@@ -439,25 +438,22 @@ class ContentComparer:
         pass
 
     def compare(self, ref_file, l10n):
         try:
             p = parser.getParser(ref_file.file)
         except UserWarning:
             # no comparison, XXX report?
             return
-        if ref_file not in self.reference:
-            # we didn't parse this before
-            try:
-                p.readContents(ref_file.getContents())
-            except Exception, e:
-                self.notify('error', ref_file, str(e))
-                return
-            self.reference[ref_file] = p.parse()
-        ref = self.reference[ref_file]
+        try:
+            p.readContents(ref_file.getContents())
+        except Exception, e:
+            self.notify('error', ref_file, str(e))
+            return
+        ref = p.parse()
         ref_list = ref[1].keys()
         ref_list.sort()
         try:
             p.readContents(l10n.getContents())
             l10n_entities, l10n_map = p.parse()
             l10n_ctx = p.ctx
         except Exception, e:
             self.notify('error', l10n, str(e))