From 7b5f7772ce59e4a2caf632b495a364f1e85e7839 Mon Sep 17 00:00:00 2001
From: hobbs <hobbs>
Date: Wed, 6 Sep 2006 19:53:22 +0000
Subject: 	* generic/tkText.c (DeleteChars): backport of 8.5 text delete 
 speedup that removes tags from deleted area first. [Bug 1456342]

---
 ChangeLog        |  5 +++++
 generic/tkText.c | 21 ++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index c7dba42..b88b3ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-06  Jeff Hobbs  <jeffh@ActiveState.com>
+
+	* generic/tkText.c (DeleteChars): backport of 8.5 text delete
+	speedup that removes tags from deleted area first. [Bug 1456342]
+
 2006-08-30  Jeff Hobbs  <jeffh@ActiveState.com>
 
 	* win/tkWinKey.c: Add WM_UNICHAR window message support (used by
diff --git a/generic/tkText.c b/generic/tkText.c
index f1fb16d..a06b90f 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -14,7 +14,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * RCS: @(#) $Id: tkText.c,v 1.33.2.1 2006/04/05 19:48:43 hobbs Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.33.2.2 2006/09/06 19:53:22 hobbs Exp $
  */
 
 #include "default.h"
@@ -1585,6 +1585,25 @@ DeleteChars(textPtr, index1String, index2String, indexPtr1, indexPtr2)
 	}
     }
 
+    if (line1 < line2) {
+	/*
+	 * We are deleting more than one line. For speed, we remove all tags
+	 * from the range first. If we don't do this, the code below can (when
+	 * there are many tags) grow non-linearly in execution time.
+	 * [Bug 1456342]
+	 */
+
+	Tcl_HashSearch search;
+	Tcl_HashEntry *hPtr;
+
+	for (hPtr=Tcl_FirstHashEntry(&textPtr->tagTable, &search);
+	     hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+	    TkTextTag *tagPtr = (TkTextTag *) Tcl_GetHashValue(hPtr);
+
+	    TkBTreeTag(&index1, &index2, tagPtr, 0);
+	}
+    }
+
     /*
      * Tell the display what's about to happen so it can discard
      * obsolete display information, then do the deletion.  Also,
-- 
cgit v0.12