From acc1e657ead019fd3e0835cadddf4d39a7b9f181 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 16 Jul 2009 18:40:24 +0400 Subject: [PATCH] * Fix indexes in fuzzy hashes calculations * Add optimization flags support * Enable -O by default --- CMakeLists.txt | 8 +++++++- src/fuzzy.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2d2cbc12..4c4dcbb728 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,8 +265,14 @@ ELSE (MD5_INCLUDE) MESSAGE(STATUS "WARNING: Using internal MD5 support") ENDIF (MD5_INCLUDE) +IF(ENABLE_OPTIMIZATION MATCHES "ON") + SET(CMAKE_C_OPT_FLAGS "-O3") +ELSE(ENABLE_OPTIMIZATION MATCHES "ON") + SET(CMAKE_C_OPT_FLAGS "-O") +ENDIF(ENABLE_OPTIMIZATION MATCHES "ON") + SET(CMAKE_C_WARN_FLAGS "-Wall -W -Wpointer-arith -Wno-unused-parameter -Wno-unused-function -Wunused-variable -Wno-sign-compare -Wunused-value -Wno-declaration-after-statement -Wno-pointer-sign") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS} -std=c99") +SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS} -std=c99") # Platform specific routines IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") diff --git a/src/fuzzy.c b/src/fuzzy.c index 49bb9da276..9e49649aa7 100644 --- a/src/fuzzy.c +++ b/src/fuzzy.c @@ -63,7 +63,7 @@ fuzzy_roll_hash (char c) rs.h[2] <<= 5; rs.h[2] ^= c; - return rs.h[1] + rs.h[2] + rs.h[3]; + return rs.h[0] + rs.h[1] + rs.h[2]; } /* A simple non-rolling hash, based on the FNV hash */ -- 2.47.3