]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Super-elegant patch by Tim Peters that speeds up colorization
authorGuido van Rossum <guido@python.org>
Thu, 22 Apr 1999 13:38:40 +0000 (13:38 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 22 Apr 1999 13:38:40 +0000 (13:38 +0000)
dramatically (up to 15 times he claims).  Works by reading more than
one line at a time, up to 100-line chunks (starting with one line and
then doubling up to the limit).  On a typical machine (e.g. Tim's
P5-166) this doesn't reduce interactive responsiveness in a noticeable
way.

Tools/idle/ColorDelegator.py

index 5b4da7cd3db21b77a8845dcd2fbcfc4b9949a6f8..147f749d9768f6c2667607d7e19505eac44f3492 100644 (file)
@@ -180,9 +180,12 @@ class ColorDelegator(Delegator):
 
             chars = ""
             mark = head
+            lines_to_get = 1
             is_ok = was_ok = 0
             while not (was_ok and is_ok):
-                next = self.index(mark + " lineend +1c")
+                next = self.index(mark + "+%d lines linestart" %
+                                         lines_to_get)
+                lines_to_get = min(lines_to_get * 2, 100)
                 was_ok = "SYNC" in self.tag_names(next + "-1c")
                 line = self.get(mark, next)
                 ##print head, "get", mark, next, "->", `line`