summaryrefslogtreecommitdiffstats
path: root/src/H5checksum.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-12-20 20:36:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-12-20 20:36:08 (GMT)
commit6878261a432d9cc8c705aa6c4f85450b29b37150 (patch)
tree765a4e072ef63bdda33320ca2c16938c5fa7a06f /src/H5checksum.c
parent79a96581a64a4b2f8a6679100a7f369bb963ab94 (diff)
downloadhdf5-6878261a432d9cc8c705aa6c4f85450b29b37150.zip
hdf5-6878261a432d9cc8c705aa6c4f85450b29b37150.tar.gz
hdf5-6878261a432d9cc8c705aa6c4f85450b29b37150.tar.bz2
[svn-r14353] Description:
- Add hash value for skip list string types, to reduce # of string comparisons. - Fixed bug with metadata/small data block aggregator adding size == 0 block into file free space list. - Refactored metadata/small data block aggregator code into single set of common routines. - Changed block aggregator code to be smarter about releasing space in the 'other' block when the 'other' block has aggregated enough data. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.4.10 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'src/H5checksum.c')
-rw-r--r--src/H5checksum.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/H5checksum.c b/src/H5checksum.c
index f2e344d..e42f152 100644
--- a/src/H5checksum.c
+++ b/src/H5checksum.c
@@ -459,3 +459,36 @@ H5_checksum_metadata(const void *data, size_t len, uint32_t initval)
FUNC_LEAVE_NOAPI(H5_checksum_lookup3(data, len, initval))
} /* end H5_checksum_metadata() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5_hash_string
+ *
+ * Purpose: Provide a simple & fast routine for hashing strings
+ *
+ * Note: This algorithm is the 'djb2' algorithm described on this page:
+ * http://www.cse.yorku.ca/~oz/hash.html
+ *
+ * Return: hash of input string (can't fail)
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, December 11, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+uint32_t
+H5_hash_string(const char *str)
+{
+ uint32_t hash = 5381;
+ int c;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5_hash_string)
+
+ /* Sanity check */
+ HDassert(str);
+
+ while(c = *str++)
+ hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
+
+ FUNC_LEAVE_NOAPI(hash)
+} /* end H5_hash_string() */
+