[Commits] textview.c 1.96.2.250 1.96.2.251

colin at claws-mail.org colin at claws-mail.org
Thu Oct 25 09:43:36 CEST 2012


Update of /home/claws-mail/claws/src
In directory srv:/tmp/cvs-serv7001/src

Modified Files:
      Tag: gtk2
	textview.c 
Log Message:
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

Index: textview.c
===================================================================
RCS file: /home/claws-mail/claws/src/textview.c,v
retrieving revision 1.96.2.250
retrieving revision 1.96.2.251
diff -u -d -r1.96.2.250 -r1.96.2.251
--- textview.c	25 Oct 2012 07:42:07 -0000	1.96.2.250
+++ textview.c	25 Oct 2012 07:43:34 -0000	1.96.2.251
@@ -1361,34 +1361,21 @@
 	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 @@
 	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 */



More information about the Commits mailing list