]> source.dussan.org Git - rspamd.git/commitdiff
Improve linear processing slightly.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 6 Jun 2015 21:10:13 +0000 (22:10 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 6 Jun 2015 21:10:13 +0000 (22:10 +0100)
src/libserver/symbols_cache.c

index 5fcb35782bf1011c44cf921a73849b9dbff83ad1..8b527262087fd36b30ea90667dbd190493d2cdaf 100644 (file)
@@ -732,6 +732,8 @@ rspamd_symbols_cache_validate (struct symbols_cache *cache,
 struct cache_savepoint {
        guchar *processed_bits;
        guint processed_num;
+       guint pass;
+       gint offset;
 };
 
 gboolean
@@ -755,6 +757,8 @@ rspamd_symbols_cache_process_symbol (struct rspamd_task * task,
                /* Inverse to use ffs */
                memset (checkpoint->processed_bits, 0xff, NBYTES (cache->used_items));
                checkpoint->processed_num = 0;
+               checkpoint->pass = 0;
+               checkpoint->offset = 0;
                *save = checkpoint;
        }
        else {
@@ -767,13 +771,17 @@ rspamd_symbols_cache_process_symbol (struct rspamd_task * task,
        }
 
        /* TODO: too slow approach */
-       for (i = 0; i < (gint)cache->used_items; i ++) {
+       for (i = checkpoint->offset * NBBY; i < (gint)cache->used_items; i ++) {
                if (isset (checkpoint->processed_bits, i)) {
                        idx = i;
                        break;
                }
        }
 
+       if (idx >= (checkpoint->offset + 1) * NBBY) {
+               checkpoint->offset ++;
+       }
+
        g_assert (idx >= 0 && idx < (gint)cache->items_by_order->len);
        item = g_ptr_array_index (cache->items_by_order, idx);