[meld] Myers matcher performance improvement
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Myers matcher performance improvement
- Date: Thu, 26 Aug 2010 20:09:05 +0000 (UTC)
commit 637e4353e4b74e245af392b33f27f7e431a0a89a
Author: Piotr Piastucki <the_leech users berlios de>
Date: Mon Jul 12 00:05:37 2010 +0200
Myers matcher performance improvement
meld/matchers.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/meld/matchers.py b/meld/matchers.py
index fb81c24..f9ed34d 100644
--- a/meld/matchers.py
+++ b/meld/matchers.py
@@ -101,17 +101,23 @@ class MyersSequenceMatcher(difflib.SequenceMatcher):
# discard lines that do not match any line from the other file
if n > 0 and m > 0:
+ aset = set()
+ bset = set()
+ for newline in b:
+ bset.add(newline)
+ for newline in a:
+ aset.add(newline)
a2 = []
b2 = []
j = 0
for i, newline in enumerate(b):
- if newline in a:
+ if newline in aset:
b2.append(newline)
bindex[j] = i
j += 1
k = 0
for i, origline in enumerate(a):
- if origline in b:
+ if origline in bset:
a2.append(a[i])
aindex[k] = i
k += 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]