[meld] filediff: Fix bug with very many opcodes being cycled through the cache



commit 4391221dbd827afba88c6b88f7dfd9592cfc1dbf
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Oct 12 06:54:35 2014 +1000

    filediff: Fix bug with very many opcodes being cycled through the cache
    
    In some situations where we, for example, did a replace all that caused
    many inline highlighting requests to pile through the cache, it was
    possible that between checking that we had the cached opcodes and
    actually returning those opcodes in the mainloop, the opcodes would be
    evicted from the cache. With this change, we keep an in-scope copy of
    the cached opcodes around so that this won't happen.

 meld/filediff.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 162c509..33ce9ab 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -78,10 +78,11 @@ class CachedSequenceMatcher(object):
     def match(self, text1, textn, cb):
         try:
             self.cache[(text1, textn)][1] = time.time()
+            opcodes = self.cache[(text1, textn)][0]
             # FIXME: This idle should be totally unnecessary, and yet nothing
             # gets highlighted without it, even though everything in the
             # callback appears to run identically.
-            GLib.idle_add(lambda: cb(self.cache[(text1, textn)][0]))
+            GLib.idle_add(lambda: cb(opcodes))
         except KeyError:
             def inline_cb(opcodes):
                 self.cache[(text1, textn)] = [opcodes, time.time()]


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