[Xfce4-commits] <midori:master> Speedup adblock by removing greedy regex if we have 1 or 2 signatures

Christian Dywan noreply at xfce.org
Thu Jan 14 02:30:01 CET 2010


Updating branch refs/heads/master
         to 4dae65d80242c9c3c5bc22931132b64d53da863f (commit)
       from 11ff993ecde4b98dd5e71613946bf5616fc23410 (commit)

commit 4dae65d80242c9c3c5bc22931132b64d53da863f
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Thu Jan 14 01:52:43 2010 +0100

    Speedup adblock by removing greedy regex if we have 1 or 2 signatures

 extensions/adblock.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/extensions/adblock.c b/extensions/adblock.c
index 26ec537..042cfde 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -926,6 +926,7 @@ adblock_compile_regexp (GHashTable* tbl,
     if (!g_regex_match_simple ("^/.*[\\^\\$\\*].*/$", patt, G_REGEX_UNGREEDY, G_REGEX_MATCH_NOTEMPTY))
     {
         int len = strlen (patt);
+        int signature_count = 0;
         for (pos = len - SIGNATURE_SIZE; pos >= 0; pos--) {
             sig = g_strndup (patt + pos, SIGNATURE_SIZE);
             if (!g_regex_match_simple ("[\\*]", sig, G_REGEX_UNGREEDY, G_REGEX_MATCH_NOTEMPTY) &&
@@ -933,6 +934,7 @@ adblock_compile_regexp (GHashTable* tbl,
             {
                 /* g_debug ("sig: %s %s", sig, patt); */
                 g_hash_table_insert (keystbl, sig, regex);
+                signature_count++;
             }
             else
             {
@@ -945,6 +947,8 @@ adblock_compile_regexp (GHashTable* tbl,
                 g_free (sig);
             }
         }
+        if (signature_count > 1 && g_hash_table_lookup (tbl, opts))
+            g_hash_table_steal (tbl, opts);
     }
     else
     {



More information about the Xfce4-commits mailing list