diff options
author | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-23 19:44:50 +0000 |
---|---|---|
committer | strank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2008-07-23 19:44:50 +0000 |
commit | 9878aff2fb3421f1a31681d361cc24d1ef3e1a5b (patch) | |
tree | 8b1cb8accd2b1843d83838796a738e1b4a93faa3 /test/docutils_difflib.py | |
parent | 83816c45579ffbfab7206e21818ecdd12ddcd8f6 (diff) | |
download | docutils-abolish-userstring-haskey@5608.tar.gz |
undo accidental commit to trunkabolish-userstring-haskey@5608
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@5608 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'test/docutils_difflib.py')
-rw-r--r-- | test/docutils_difflib.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/docutils_difflib.py b/test/docutils_difflib.py index 1865c2117..a41d4d5ba 100644 --- a/test/docutils_difflib.py +++ b/test/docutils_difflib.py @@ -163,6 +163,8 @@ class SequenceMatcher: # b2j # for x in b, b2j[x] is a list of the indices (into b) # at which x appears; junk elements do not appear + # b2jhas + # b2j.has_key # fullbcount # for x in b, fullbcount[x] == the number of times x # appears in b; only materialized if really needed (used @@ -186,7 +188,7 @@ class SequenceMatcher: # DON'T USE! Only __chain_b uses this. Use isbjunk. # isbjunk # for x in b, isbjunk(x) == isjunk(x) but much faster; - # it's really the in operator of a hidden dict. + # it's really the has_key method of a hidden dict. # DOES NOT WORK for x in a! self.isjunk = isjunk @@ -283,9 +285,10 @@ class SequenceMatcher: # from the start. b = self.b self.b2j = b2j = {} + self.b2jhas = b2jhas = b2j.has_key for i in xrange(len(b)): elt = b[i] - if elt in b2j: + if b2jhas(elt): b2j[elt].append(i) else: b2j[elt] = [i] @@ -301,12 +304,12 @@ class SequenceMatcher: junkdict[elt] = 1 # value irrelevant; it's a set del b2j[elt] - # Now for x in b, isjunk(x) == x in junkdict, but the + # Now for x in b, isjunk(x) == junkdict.has_key(x), but the # latter is much faster. Note too that while there may be a # lot of junk in the sequence, the number of *unique* junk # elements is probably small. So the memory burden of keeping # this dict alive is likely trivial compared to the size of b2j. - self.isbjunk = lambda elt: elt in junkdict + self.isbjunk = junkdict.has_key def find_longest_match(self, alo, ahi, blo, bhi): """Find longest matching block in a[alo:ahi] and b[blo:bhi]. @@ -547,9 +550,9 @@ class SequenceMatcher: # avail[x] is the number of times x appears in 'b' less the # number of times we've seen it in 'a' so far ... kinda avail = {} - matches = 0 + availhas, matches = avail.has_key, 0 for elt in self.a: - if elt in avail: + if availhas(elt): numb = avail[elt] else: numb = fullbcount.get(elt, 0) |