[Opensrf-commits] r1726 - in trunk: include/opensrf src/libopensrf (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jul 21 23:50:13 EDT 2009


Author: scottmk
Date: 2009-07-21 23:50:13 -0400 (Tue, 21 Jul 2009)
New Revision: 1726

Modified:
   trunk/include/opensrf/osrf_hash.h
   trunk/src/libopensrf/osrf_hash.c
Log:
This is a performance tweak to the osrfHashGet function, a widely
used utility function.

The old version accepted a variable number of arguments: a pointer
to an osrfHash, a string optionally containing printf-style
format specifiers, and addtional parameters as needed to fill in
the blanks.

In practice, none of the code ever uses the printf-style formatting.
We always pass exactly two parameters.  We burn CPU cycles scanning
the string for format specifiers and never find any.

I eliminated the unused variable parameters and turned osrfHashGet()
into a simple two-parameter function.  Just in case anybody ever
wants it, I also cloned the original version into a new function
named osrfHashGetFmt, which accepts a variable number of arguments
as before.

Note that, since the signature of the function is changing,
it is necessary to recompile any open-ils programs that
call it, namely:

oils_dataloader.c
oils_event.c
oils_idl-core.c
oils_cstore.c
dump_idl.c

The Makefiles apparently don't recognize this dependency.


Modified: trunk/include/opensrf/osrf_hash.h
===================================================================
--- trunk/include/opensrf/osrf_hash.h	2009-07-10 15:28:50 UTC (rev 1725)
+++ trunk/include/opensrf/osrf_hash.h	2009-07-22 03:50:13 UTC (rev 1726)
@@ -42,8 +42,9 @@
   */
 void* osrfHashRemove( osrfHash* hash, const char* key, ... );
 
-void* osrfHashGet( osrfHash* hash, const char* key, ... );
+void* osrfHashGet( osrfHash* hash, const char* key );
 
+void* osrfHashGetFmt( osrfHash* hash, const char* key, ... );
 
 /**
   @return A list of strings representing the keys of the hash. 

Modified: trunk/src/libopensrf/osrf_hash.c
===================================================================
--- trunk/src/libopensrf/osrf_hash.c	2009-07-10 15:28:50 UTC (rev 1725)
+++ trunk/src/libopensrf/osrf_hash.c	2009-07-22 03:50:13 UTC (rev 1726)
@@ -252,7 +252,13 @@
 }
 
 
-void* osrfHashGet( osrfHash* hash, const char* key, ... ) {
+void* osrfHashGet( osrfHash* hash, const char* key ) {
+	osrfHashNode* node = find_item( hash, key, NULL );
+	if( !node ) return NULL;
+	return node->item;
+}
+
+void* osrfHashGetFmt( osrfHash* hash, const char* key, ... ) {
 	if(!(hash && key )) return NULL;
 	VA_LIST_TO_STRING(key);
 



More information about the opensrf-commits mailing list