]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add performance comments to VG_(sizeFM), and add new method
authorJulian Seward <jseward@acm.org>
Thu, 13 Nov 2008 13:17:06 +0000 (13:17 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 13 Nov 2008 13:17:06 +0000 (13:17 +0000)
VG_(isEmptyFM), currently commented out.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8765

coregrind/m_wordfm.c
include/pub_tool_wordfm.h

index 2ddc795dc993281bd1078a1e490b86df9faf60e5..90389cd4d9383b07d9a0f19ef298ea41de2e955a 100644 (file)
@@ -683,12 +683,19 @@ Bool VG_(findBoundsFM)( WordFM* fm,
                                      key, fm->kCmp );
 }
 
+// See comment in pub_tool_wordfm.h for performance warning
 UWord VG_(sizeFM) ( WordFM* fm )
 {
    // Hmm, this is a bad way to do this
    return fm->root ? size_avl_nonNull( fm->root ) : 0;
 }
 
+// NB UNTESTED!  TEST BEFORE USE!
+//Bool VG_(isEmptyFM)( WordFM* fm )
+//{
+//   return fm->root ? False : True;
+//}
+
 // set up FM for iteration
 void VG_(initIterFM) ( WordFM* fm )
 {
index 7b9949024df3fcfd4c684fd641fe9e5dcd692bc5..6302a9a25b82d4f6cd067cb25e153a734d001a4d 100644 (file)
@@ -122,9 +122,16 @@ Bool VG_(findBoundsFM)( WordFM* fm,
                         UWord maxKey, UWord maxVal,
                         UWord key );
 
-// How many elements are there in fm?
+// How many elements are there in fm?  NOTE: dangerous in the
+// sense that this is not an O(1) operation but rather O(N),
+// since it involves walking the whole tree.
 UWord VG_(sizeFM) ( WordFM* fm );
 
+// Is fm empty?  This at least is an O(1) operation.
+// Code is present in m_wordfm.c but commented out due to no
+// current usage.  Un-comment (and TEST IT) if required.
+//Bool VG_(isEmptyFM)( WordFM* fm );
+
 // set up FM for iteration
 void VG_(initIterFM) ( WordFM* fm );