summaryrefslogtreecommitdiff
path: root/src/staticstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/staticstring.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/staticstring.cpp b/src/staticstring.cpp
index 9eac92e..0012b0f 100644
--- a/src/staticstring.cpp
+++ b/src/staticstring.cpp
@@ -243,10 +243,28 @@ bool StaticString::operator!=( StaticString &str )
243unsigned long int StaticString::getHashCode() 243unsigned long int StaticString::getHashCode()
244{ 244{
245 unsigned long int nPos = nLen; 245 unsigned long int nPos = nLen;
246 for( const char *s = (const char *)lpStr; *s; s++ ) 246 unsigned long int j = 0;
247 for( const char *s = (const char *)lpStr; j< nLen; s++, j++ )
247 { 248 {
248 nPos = *s + (nPos << 6) + (nPos << 16) - nPos; 249 nPos = *s + (nPos << 6) + (nPos << 16) - nPos;
249 } 250 }
250 return nPos; 251 return nPos;
251} 252}
252 253
254bool StaticString::compareForHash( Hashable &other )
255{
256 if( ((StaticString &)other).nLen != nLen )
257 return false;
258
259 const char *a = ((StaticString &)other).lpStr;
260 const char *b = lpStr;
261 if( a == b )
262 return true;
263
264 for( unsigned long j = 0; j < nLen; j++, a++, b++ )
265 if( *a != *b )
266 return false;
267
268 return true;
269}
270