From e4c49643c47f4d69282a8d1ad2f05619bd4d86b9 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Sun, 26 Dec 2010 10:18:22 -0600 Subject: Only do second sum if it can make a difference --- lcs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lcs.c b/lcs.c index b971c79..f3a6203 100644 --- a/lcs.c +++ b/lcs.c @@ -158,7 +158,7 @@ int lcs_32_rough(unsigned char *str1, unsigned char *str2) { #endif #ifdef USE_PRE_LCS -//efine DO_SECOND_SUM +#define DO_SECOND_SUM #ifdef DO_SECOND_SUM #include "arpa/inet.h" @@ -188,7 +188,9 @@ int lcs_upper_bound(const uint32_t * const str1_int, const uint32_t * const str2 // can be off up to two nibbles (e.g., "0110" and "1122") ret = first_sum * 2 + 2; #ifdef DO_SECOND_SUM - if (ret >= MSF) { + // We can only increase our accuracy by 1, so do second_sum only if we can + // turn a false-positive into a negative + if (ret == MSF) { uint32_t bo_str2_int[4]; uint32_t shifted_str2_int[4]; const unsigned char * const str2_r = (const unsigned char * const)shifted_str2_int; -- cgit v1.2.3-54-g00ecf