Bug 700659 - add a Contains method to nsTHashtable; r=bsmedberg
authorNathan Froyd <froydnj@mozilla.com>
Wed, 22 Feb 2012 06:32:13 -0800
changeset 87737 7aaa5f1f685e5fb372c83372820ef62322036993
parent 87736 d0679906670729207d07e450a9804a528020fcb2
child 87738 f66366413f66939041e4faa0307356fef1dd06f4
push id22143
push userphilringnalda@gmail.com
push dateSun, 26 Feb 2012 23:12:35 +0000
treeherdermozilla-central@b98fc24ac54b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs700659
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 700659 - add a Contains method to nsTHashtable; r=bsmedberg
xpcom/glue/nsTHashtable.h
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -167,16 +167,26 @@ public:
                       (PL_DHashTableOperate(
                             const_cast<PLDHashTable*>(&mTable),
                             EntryType::KeyToPointer(aKey),
                             PL_DHASH_LOOKUP));
     return PL_DHASH_ENTRY_IS_BUSY(entry) ? entry : nsnull;
   }
 
   /**
+   * Return true if an entry for the given key exists, false otherwise.
+   * @param     aKey the key to retrieve
+   * @return    true if the key exists, false if the key doesn't exist
+   */
+  bool Contains(KeyType aKey) const
+  {
+    return !!GetEntry(aKey);
+  }
+
+  /**
    * Get the entry associated with a key, or create a new entry,
    * @param     aKey the key to retrieve
    * @return    pointer to the entry class retreived; nsnull only if memory
                 can't be allocated
    */
   EntryType* PutEntry(KeyType aKey)
   {
     NS_ASSERTION(mTable.entrySize, "nsTHashtable was not initialized properly.");