diff options
| author | Eric Anderson <ejona86@gmail.com> | 2010-12-26 10:01:42 -0600 | 
|---|---|---|
| committer | Eric Anderson <ejona86@gmail.com> | 2010-12-26 10:01:42 -0600 | 
| commit | 4c91b8ea5950834693130343899e0fa379fd3be1 (patch) | |
| tree | b04e5a876689e6338e2b14c43d59541e6bc169e8 | |
| parent | 3824e95334e06d9c1309591e7a040dc7b4049ff5 (diff) | |
| download | md5game-4c91b8ea5950834693130343899e0fa379fd3be1.tar.gz md5game-4c91b8ea5950834693130343899e0fa379fd3be1.zip  | |
Simple movement of return calculation in lcs_upper_bound
This increased performance of the non-DO_SECOND_SUM code a _lot_ for something
so small.
| -rw-r--r-- | lcs.c | 17 | 
1 files changed, 9 insertions, 8 deletions
@@ -158,7 +158,7 @@ int lcs_32_rough(unsigned char *str1, unsigned char *str2) {  #endif  #ifdef USE_PRE_LCS -#define DO_SECOND_SUM +//efine DO_SECOND_SUM  #ifdef DO_SECOND_SUM  #include "arpa/inet.h" @@ -169,6 +169,7 @@ int lcs_upper_bound(const uint32_t * const str1_int, const uint32_t * const str2      const unsigned char * const str1 = (const unsigned char * const)str1_int;      const unsigned char * const str2 = (const unsigned char * const)str2_int;      int first_sum; +    int ret;  #ifdef DO_SECOND_SUM      uint32_t bo_str2_int[4];      uint32_t shifted_str2_int[4]; @@ -207,6 +208,12 @@ int lcs_upper_bound(const uint32_t * const str1_int, const uint32_t * const str2          + contains[str2_r[9]] + contains[str2_r[10]] + contains[str2_r[11]]          + contains[str2_r[12]] + contains[str2_r[13]] + contains[str2_r[14]]          + contains[str2_r[15]]; + +    // can be off up to one nibble (e.g., "1110" and "2111") +    ret = MAX(first_sum, second_sum) * 2 + 1; +#else +    // can be off up to two nibbles (e.g., "0110" and "1122") +    ret = first_sum * 2 + 2;  #endif      contains[str1[0]] = contains[str1[1]] = contains[str1[2]] @@ -216,13 +223,7 @@ int lcs_upper_bound(const uint32_t * const str1_int, const uint32_t * const str2          = contains[str1[12]] = contains[str1[13]] = contains[str1[14]]          = contains[str1[15]] = 0; -#ifdef DO_SECOND_SUM -    // can be off up to one nibble (e.g., "1110" and "2111") -    return MAX(first_sum, second_sum) * 2 + 1; -#else -    // can be off up to two nibbles (e.g., "0110" and "1122") -    return first_sum * 2 + 2; -#endif +    return ret;  }  #endif  | 
