From 7b8cb00259043365e001992229dfaf50c60dd66b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 10 Jul 2007 02:15:01 +0000 Subject: More FString updates, this one fixes the hashing and string comparison. --- src/fstring.cpp | 11 ++++++++++- src/fstring.h | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/fstring.cpp b/src/fstring.cpp index f71d6c1..429dfef 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -3,7 +3,16 @@ template<> uint32_t Bu::__calcHashCode( const Bu::FString &k ) { - return __calcHashCode( k.c_str() ); + long j, sz = k.getSize(); + const char *s = k.getStr(); + + long nPos = 0; + for( j = 0; j < sz; j++, s++ ) + { + nPos = *s + (nPos << 6) + (nPos << 16) - nPos; + } + + return nPos; } template<> bool Bu::__cmpHashKeys( diff --git a/src/fstring.h b/src/fstring.h index 73b04ab..31794d7 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -418,12 +418,14 @@ namespace Bu return true; if( pFirst == NULL ) return false; + if( nLength != pData.nLength ) + return false; flatten(); pData.flatten(); const chr *a = pData.pFirst->pData; chr *b = pFirst->pData; - for( ; *a!=(chr)0 || *b!=(chr)0; a++, b++ ) + for( long j = 0; j < nLength; j++, a++, b++ ) { if( *a != *b ) return false; -- cgit v1.2.3