2012-10-25 [colin] 3.8.1cvs105
authorColin Leroy <colin@colino.net>
Thu, 25 Oct 2012 07:43:36 +0000 (07:43 +0000)
committerColin Leroy <colin@colino.net>
Thu, 25 Oct 2012 07:43:36 +0000 (07:43 +0000)
* src/textview.c
Do not allow search cost to explode in case of bad message
parsing in textview_make_clickable_parts_later(); reduces
cost of textview_make_clickable_parts_later() from 99% to
17% for big bad-case message. Patch by Igor Mammedov

ChangeLog
PATCHSETS
configure.ac
src/textview.c

index d73970e..60736b9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-10-25 [colin]     3.8.1cvs105
+
+       * src/textview.c
+               Do not allow search cost to explode in case of bad message
+               parsing in textview_make_clickable_parts_later(); reduces
+               cost of textview_make_clickable_parts_later() from 99% to
+               17% for big bad-case message. Patch by Igor Mammedov
+
 2012-10-25 [colin]     3.8.1cvs104
 
        * src/textview.c
index 44f918a..c2376f3 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.100.2.84 -r 1.100.2.85 AUTHORS;  cvs diff -u -r 1.23.2.39 -r 1.23.2.40 src/crash.c;  cvs diff -u -r 1.1.2.80 -r 1.1.2.81 src/gtk/authors.h;  ) > 3.8.1cvs102.patchset
 ( cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/advsearch.c;  ) > 3.8.1cvs103.patchset
 ( cvs diff -u -r 1.100.2.85 -r 1.100.2.86 AUTHORS;  cvs diff -u -r 1.96.2.249 -r 1.96.2.250 src/textview.c;  cvs diff -u -r 1.12.2.35 -r 1.12.2.36 src/textview.h;  cvs diff -u -r 1.1.2.81 -r 1.1.2.82 src/gtk/authors.h;  ) > 3.8.1cvs104.patchset
+( cvs diff -u -r 1.96.2.250 -r 1.96.2.251 src/textview.c;  ) > 3.8.1cvs105.patchset
index 1be67d3..c6e1375 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=8
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=104
+EXTRA_VERSION=105
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8c4b6e7..c1f06e0 100644 (file)
@@ -1361,34 +1361,21 @@ static void textview_make_clickable_parts(TextView *textview,
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
        /* parse for clickable parts, and build a list of begin and end positions  */
-       for (walk = mybuf;;) {
-               gint last_index = PARSE_ELEMS;
-               gchar *scanpos = NULL;
-
-               /* FIXME: this looks phony. scanning for anything in the parse table */
-               for (n = 0; n < PARSE_ELEMS; n++) {
-                       gchar *tmp;
-
-                       tmp = parser[n].search(walk, parser[n].needle);
-                       if (tmp) {
-                               if (scanpos == NULL || tmp < scanpos) {
-                                       scanpos = tmp;
-                                       last_index = n;
-                               }
-                       }                                       
-               }
-
-               if (scanpos) {
-                       /* check if URI can be parsed */
-                       if (parser[last_index].parse(walk, scanpos, &bp, &ep, hdr)
-                           && (size_t) (ep - bp - 1) > strlen(parser[last_index].needle)) {
-                                       ADD_TXT_POS(bp, ep, last_index);
+       for (n = 0; n < PARSE_ELEMS; n++) {
+               for (walk = mybuf;;) {
+                       gchar *scanpos = parser[n].search(walk, parser[n].needle);
+                       if (scanpos) {
+                               /* check if URI can be parsed */
+                               if (parser[n].parse(walk, scanpos, &bp, &ep, hdr)
+                                               && (size_t) (ep - bp - 1) > strlen(parser[n].needle)) {
+                                       ADD_TXT_POS(bp, ep, n);
                                        walk = ep;
+                               } else
+                                       walk = scanpos +
+                                               strlen(parser[n].needle);
                        } else
-                               walk = scanpos +
-                                       strlen(parser[last_index].needle);
-               } else
-                       break;
+                               break;
+               }
        }
 
        /* colorize this line */
@@ -1481,34 +1468,21 @@ static void textview_make_clickable_parts_later(TextView *textview,
        offset = gtk_text_iter_get_offset(&start_iter);
 
        /* parse for clickable parts, and build a list of begin and end positions  */
-       for (walk = mybuf;;) {
-               gint last_index = PARSE_ELEMS;
-               gchar *scanpos = NULL;
-
-               /* FIXME: this looks phony. scanning for anything in the parse table */
-               for (n = 0; n < PARSE_ELEMS; n++) {
-                       gchar *tmp;
-
-                       tmp = parser[n].search(walk, parser[n].needle);
-                       if (tmp) {
-                               if (scanpos == NULL || tmp < scanpos) {
-                                       scanpos = tmp;
-                                       last_index = n;
-                               }
-                       }                                       
-               }
-
-               if (scanpos) {
-                       /* check if URI can be parsed */
-                       if (parser[last_index].parse(walk, scanpos, &bp, &ep, FALSE)
-                           && (size_t) (ep - bp - 1) > strlen(parser[last_index].needle)) {
-                                       ADD_TXT_POS_LATER(bp, ep, last_index);
+       for (n = 0; n < PARSE_ELEMS; n++) {
+               for (walk = mybuf;;) {
+                       gchar *scanpos = parser[n].search(walk, parser[n].needle);
+                       if (scanpos) {
+                               /* check if URI can be parsed */
+                               if (parser[n].parse(walk, scanpos, &bp, &ep, FALSE)
+                                               && (size_t) (ep - bp - 1) > strlen(parser[n].needle)) {
+                                       ADD_TXT_POS_LATER(bp, ep, n);
                                        walk = ep;
+                               } else
+                                       walk = scanpos +
+                                               strlen(parser[n].needle);
                        } else
-                               walk = scanpos +
-                                       strlen(parser[last_index].needle);
-               } else
-                       break;
+                               break;
+               }
        }
 
        /* colorize this line */