summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-02-18 12:49:50 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-02-18 13:08:58 +0100
commit042725a5dadc9f2c6368ca451b6d20046129b8af (patch)
treec43b1359bcef882985a06303551a227825d1e5a8 /include/rtl
parentf2529fc7441ced32daef09c0ca767080998d1792 (diff)
Stick to a single O[U]String hash function
8f8bc0dcf3bc253ae49159d52db049767f476ced "Move string hash function into String class" had introduced a new getHash64 that, besides returning sal_uInt64 instead of just sal_Int32, didn't do sampling of only a handful of characters, but always computed the hash over all characters (as the usage in SfxItemSet and SdPage appears to require for either performance or approximated correctness). However, it would be advantageous to keep the stable URE interface as small as possible. Now, O(1) sampling was apparently considered state of the art when the rtl string classes were first created, closely copying java.lang.String, which at that time demanded sampling for hashCode(), too---but never sampling more than 15 characters, with the obvious (in hindsight, at least) performance catastrophes, so they changed it to O(n) somewhere along the way. Based on that, this commit changes the existing hash functions to not do sampling any more, and removes the newly introduced -64 variants again. (Where the extended value range of sal_uInt64 compared to sal_Int32 was hopefully not vital to the existing uses.) The old implementation used sampling only for strings of length >= 256, so I did a "make check" build with an instrumented hash function that flagged all uses with inputs of length >= 256, and grepped workdir/{Cppunit,Junit,Python}Test for hits. Of the 2849 hits encountered, 2845 where in the range from 256 to 295 characters, and only the remaining four where of 2472 characters. Those four were from CppunitTest_sc_subsequent_filters_test, importing long text into a cell, causing ScDocumentImport::setStringCell to call svl::SharedStringPool::intern, which internally uses an unordered_set. These results appear to justify the change. Change-Id: I78fcc3b0f07389bdf36a21701b95a1ff0a0d970f
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/string.h18
-rw-r--r--include/rtl/string.hxx15
-rw-r--r--include/rtl/ustring.h18
-rw-r--r--include/rtl/ustring.hxx15
4 files changed, 0 insertions, 66 deletions
diff --git a/include/rtl/string.h b/include/rtl/string.h
index 71e095561a37..32344bfa4413 100644
--- a/include/rtl/string.h
+++ b/include/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/include/rtl/string.hxx b/include/rtl/string.hxx
index 5eb4fcf6ee1e..fb7283b3a801 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -892,21 +892,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/include/rtl/ustring.h b/include/rtl/ustring.h
index 206989934628..80c6bccf7f3d 100644
--- a/include/rtl/ustring.h
+++ b/include/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/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 9f9a9565f18f..f1a5f4aeb296 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -1227,21 +1227,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.