sal/inc/rtl/string.h | 18 ------------ sal/inc/rtl/string.hxx | 15 ---------- sal/inc/rtl/ustring.h | 18 ------------ sal/inc/rtl/ustring.hxx | 15 ---------- sal/rtl/source/strtmpl.cxx | 64 +++---------------------------------------- sal/util/sal.map | 6 ---- sd/inc/sdpage.hxx | 2 - sd/source/core/sdpage2.cxx | 4 +- sd/source/core/stlpool.cxx | 2 - svl/inc/svl/itemset.hxx | 2 - svl/source/items/itemset.cxx | 4 +- 11 files changed, 12 insertions(+), 138 deletions(-)
New commits: commit 98554820e6109c3e3f4ea83bf036d9f20ef1685e Author: Stephan Bergmann <sberg...@redhat.com> Date: Thu Feb 20 09:23:20 2014 +0530 Stick to a single O[U]String hash function Ported from: 042725a5dadc9f2c6368ca451b6d20046129b8af Change-Id: I87f11d9101e21bdadaaffb719a762d0030639cb1 diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h index 3def4c1..9f3c69a 100644 --- a/sal/inc/rtl/string.h +++ b/sal/inc/rtl/string.h @@ -277,24 +277,6 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode( SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength( const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); -/** Return a hash code (64bit) for a string. - - It is not allowed to store the hash code persistently, because later - versions could return other hash codes. - - @param str - a string. Need not be null-terminated, but must be at least as long as - the specified len. - - @param len - the length of the string. - - @return - a hash code for the given string. - */ -SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_str_hashCode64_WithLength( - const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); - /** Search for the first occurrence of a character within a string. The string must be null-terminated. diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index e9a9342..cbd4b9a 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -866,21 +866,6 @@ public: } /** - Returns a 64bit hash of the string data. - This hashes the entire data, while hashCode would do sampling for larger string sizes. - - @return a hash code value of the string data - - @see hashCode() for simple hashes - - @since LibreOffice 4.3 - */ - sal_uInt64 hashCode64() const SAL_THROW(()) - { - return rtl_str_hashCode64_WithLength( pData->buffer, pData->length ); - } - - /** Returns a hashcode for this string. @return a hash code value for this object. diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h index 24a7dd8..0352e59 100644 --- a/sal/inc/rtl/ustring.h +++ b/sal/inc/rtl/ustring.h @@ -551,24 +551,6 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode( SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength( const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); -/** Return a hash code (64bit) for a string. - - It is not allowed to store the hash code persistently, because later - versions could return other hash codes. - - @param str - a string. Need not be null-terminated, but must be at least as long as - the specified len. - - @param len - the length of the string. - - @return - a hash code for the given string. - */ -SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_hashCode64_WithLength( - const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); - /** Search for the first occurrence of a character within a string. The string must be null-terminated. diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 1f75101..36295116 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -1168,21 +1168,6 @@ public: } /** - Returns a 64bit hash of the string data. - This hashes the entire data, while hashCode would do sampling for larger string sizes. - - @return a hash code value of the string data - - @see hashCode() for simple hashes - - @since LibreOffice 4.3 - */ - sal_uInt64 hashCode64() const SAL_THROW(()) - { - return rtl_ustr_hashCode64_WithLength( pData->buffer, pData->length ); - } - - /** Returns a hashcode for this string. @return a hash code value for this object. diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx index 9b8fa51..3ba2eaf 100644 --- a/sal/rtl/source/strtmpl.cxx +++ b/sal/rtl/source/strtmpl.cxx @@ -272,72 +272,18 @@ 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() { - sal_Int32 h = nLen; - - if ( nLen < 256 ) - { - while ( nLen > 0 ) - { - h = (h*37) + IMPL_RTL_USTRCODE( *pStr ); - pStr++; - nLen--; - } - } - else + sal_uInt32 h = static_cast<sal_uInt32>(nLen); + while ( nLen > 0 ) { - sal_Int32 nSkip; - const IMPL_RTL_STRCODE* pEndStr = pStr+nLen-5; - - /* only sample some characters */ - /* the first 3, some characters between, and the last 5 */ - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); + h = (h*37U) + IMPL_RTL_USTRCODE( *pStr ); pStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); - pStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); - pStr++; - - if ( nLen < 32 ) - nSkip = nLen / 4; - else - nSkip = nLen / 8; - nLen -= 8; - while ( nLen > 0 ) - { - h = (h*39) + IMPL_RTL_USTRCODE( *pStr ); - pStr += nSkip; - nLen -= nSkip; - } - - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); - pEndStr++; - h = (h*39) + IMPL_RTL_USTRCODE( *pEndStr ); + nLen--; } - - return h; + return static_cast<sal_Int32>(h); } /* ----------------------------------------------------------------------- */ diff --git a/sal/util/sal.map b/sal/util/sal.map index 7ab421f..ade61cd 100644 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -652,12 +652,6 @@ LIBO_UDK_4.0 { # symbols available in >= LibO 4.0 rtl_uString_newReplaceAllFromIndex; } LIBO_UDK_3.6; -LIBO_UDK_4.3 { #symbols available in >= LibO 4.3 - global: - rtl_str_hashCode64_WithLength; - rtl_ustr_hashCode64_WithLength; -} LIBO_UDK_4.2; - PRIVATE_1.0 { global: osl_detail_ObjectRegistry_storeAddresses; diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx index 0c99930..422b667 100644 --- a/sd/inc/sdpage.hxx +++ b/sd/inc/sdpage.hxx @@ -382,7 +382,7 @@ public: void removeAnnotation( const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ); const sd::AnnotationVector& getAnnotations() const { return maAnnotations; } bool hasAnnotations() const { return !maAnnotations.empty(); } - sal_uInt64 getHash() const; + sal_Int32 getHash() const; virtual OString stringify() const; diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 37b16e2..b1475e6 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -599,9 +599,9 @@ OString SdPage::stringify() const return aString.makeStringAndClear(); } -sal_uInt64 SdPage::getHash() const +sal_Int32 SdPage::getHash() const { - return stringify().hashCode64(); + return stringify().hashCode(); } diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index bf8d0c3..ea4d5cf 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -674,7 +674,7 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily SfxStyleSheetBase* pExistingSheet = Find(aName, eFamily); if( pExistingSheet && !rRenameSuffix.isEmpty() ) { - sal_uInt64 nHash = xSheet->GetItemSet().getHash(); + sal_Int32 nHash = xSheet->GetItemSet().getHash(); if( pExistingSheet->GetItemSet().getHash() != nHash ) { OUString aTmpName = aName + rRenameSuffix; diff --git a/svl/inc/svl/itemset.hxx b/svl/inc/svl/itemset.hxx index 89ad83d..13b6988 100644 --- a/svl/inc/svl/itemset.hxx +++ b/svl/inc/svl/itemset.hxx @@ -151,7 +151,7 @@ public: virtual SvStream & Store( SvStream &, bool bDirect = false ) const; virtual int operator==(const SfxItemSet &) const; - virtual sal_uInt64 getHash() const; + sal_Int32 getHash() const; virtual OString stringify() const; }; diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 0037552..aa1a0ac 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -2054,9 +2054,9 @@ SfxItemSet *SfxAllItemSet::Clone(sal_Bool bItems, SfxItemPool *pToPool ) const // ----------------------------------------------------------------------- -sal_uInt64 SfxItemSet::getHash() const +sal_Int32 SfxItemSet::getHash() const { - return stringify().hashCode64(); + return stringify().hashCode(); } // ----------------------------------------------------------------------- _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits