diff options
author | Muthu Subramanian <sumuthu@collabora.com> | 2014-02-13 13:13:53 +0530 |
---|---|---|
committer | Muthu Subramanian <sumuthu@collabora.com> | 2014-02-13 13:13:53 +0530 |
commit | 8f8bc0dcf3bc253ae49159d52db049767f476ced (patch) | |
tree | 080da7007b55eac85432d41337f6ea2cda629334 /sal | |
parent | coverity#1130358 Deference after null check (diff) | |
download | core-8f8bc0dcf3bc253ae49159d52db049767f476ced.tar.gz core-8f8bc0dcf3bc253ae49159d52db049767f476ced.zip |
Move string hash function into String class.
hashCode() seems to do sampling while creating the hash.
hashCode64() will not.
Change-Id: Id30f5a2a774cf5244dbc00da9649e95a532484be
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/strtmpl.cxx | 13 | ||||
-rw-r--r-- | sal/util/sal.map | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index fc618d3f38de..f2eac10bf217 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -252,6 +252,19 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode )( const IMPL_RTL_STRCODE* pStr ) /* ----------------------------------------------------------------------- */ +sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( hashCode64_WithLength )( const IMPL_RTL_STRCODE* pStr, + sal_Int32 nLen ) + SAL_THROW_EXTERN_C() +{ + sal_uInt64 nHash = 0; + + for( sal_Int32 i = 0; i < nLen; i++ ) + nHash = (nHash << 5) - nHash + *pStr++; + return nHash; +} + +/* ----------------------------------------------------------------------- */ + sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode_WithLength )( const IMPL_RTL_STRCODE* pStr, sal_Int32 nLen ) SAL_THROW_EXTERN_C() diff --git a/sal/util/sal.map b/sal/util/sal.map index 1456d6db1cf8..470da31adf78 100644 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -221,6 +221,7 @@ UDK_3_0_0 { rtl_str_shortenedCompareIgnoreAsciiCase_WithLength; rtl_str_hashCode; rtl_str_hashCode_WithLength; + rtl_str_hashCode64_WithLength; rtl_str_indexOfChar; rtl_str_indexOfChar_WithLength; rtl_str_indexOfStr; |