[meld] filediff: Move matcher initialisation into the worker



commit 5993e19699ab1c5a4bc59814373601d6d37cd594
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Mar 1 09:44:50 2015 +1000

    filediff: Move matcher initialisation into the worker
    
    The code was previously in matchers, simply because reexecing matchers
    was safe, but filediff not so much.

 meld/filediff.py |    6 ++++--
 meld/matchers.py |    5 -----
 2 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 300df2e..e1851dd 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -53,6 +53,8 @@ log = logging.getLogger(__name__)
 
 class MatcherWorker(threading.Thread):
 
+    matcher_class = matchers.InlineMyersSequenceMatcher
+
     def __init__(self, tasks, results):
         super(MatcherWorker, self).__init__()
         self.tasks = tasks
@@ -64,8 +66,8 @@ class MatcherWorker(threading.Thread):
         while True:
             task_id, (text1, textn) = self.tasks.get()
             try:
-                opcodes = matchers.matcher_worker(text1, textn)
-                self.results.put((task_id, opcodes))
+                matcher = self.matcher_class(None, text1, textn)
+                self.results.put((task_id, matcher.get_opcodes()))
             except Exception as e:
                 log.error("Exception while running diff: %s", e)
             finally:
diff --git a/meld/matchers.py b/meld/matchers.py
index 0561034..0354883 100644
--- a/meld/matchers.py
+++ b/meld/matchers.py
@@ -18,11 +18,6 @@ import collections
 import difflib
 
 
-def matcher_worker(text1, textn):
-    matcher = InlineMyersSequenceMatcher(None, text1, textn)
-    return matcher.get_opcodes()
-
-
 def find_common_prefix(a, b):
     if not a or not b:
         return 0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]