Bug 1172782 - Change how nsTHashtable::Clear() works. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 10 Jun 2015 13:07:40 -0700
changeset 248259 9c4f6706db9a05d332c88befff1581cb1f2bc020
parent 248258 8791911ffc9500df7f4e42020cad6c7d3cfa59dc
child 248260 4636a1c2b824a1d0f6e0b4d405778572df460678
push id28893
push userkwierso@gmail.com
push dateFri, 12 Jun 2015 00:02:58 +0000
treeherderautoland@8cf9d3e497f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1172782
milestone41.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 1172782 - Change how nsTHashtable::Clear() works. r=froydnj. This change reimplements nsTHashtable::Clear() using PLDHashable::Clear(). This changes its semantics slightly -- the old version would clear the table but leave its capacity unchanged. The new version will adjust the capacity to the default, though the entry storage will only be re-allocated when the first new element is added.
xpcom/glue/nsTHashtable.cpp
xpcom/glue/nsTHashtable.h
xpcom/glue/objs.mozbuild
xpcom/libxpcomrt/moz.build
deleted file mode 100644
--- a/xpcom/glue/nsTHashtable.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsTHashtable.h"
-
-PLDHashOperator
-PL_DHashStubEnumRemove(PLDHashTable*    aTable,
-                       PLDHashEntryHdr* aEntry,
-                       uint32_t         aOrdinal,
-                       void*            aUserarg)
-{
-  return PL_DHASH_REMOVE;
-}
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -14,23 +14,16 @@
 #include "mozilla/MemoryChecking.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
 #include "mozilla/fallible.h"
 #include "mozilla/PodOperations.h"
 
 #include <new>
 
-// helper function for nsTHashtable::Clear()
-PLDHashOperator PL_DHashStubEnumRemove(PLDHashTable* aTable,
-                                       PLDHashEntryHdr* aEntry,
-                                       uint32_t aOrdinal,
-                                       void* aUserArg);
-
-
 /**
  * a base class for templated hashtables.
  *
  * Clients will rarely need to use this class directly. Check the derived
  * classes first, to see if they will meet your needs.
  *
  * @param EntryType  the templated entry-type class that is managed by the
  *   hashtable. <code>EntryType</code> must extend the following declaration,
@@ -206,21 +199,23 @@ public:
    */
   uint32_t EnumerateEntries(Enumerator aEnumFunc, void* aUserArg)
   {
     s_EnumArgs args = { aEnumFunc, aUserArg };
     return PL_DHashTableEnumerate(&mTable, s_EnumStub, &args);
   }
 
   /**
-   * remove all entries, return hashtable to "pristine" state ;)
+   * Remove all entries, return hashtable to "pristine" state. It's
+   * conceptually the same as calling the destructor and then re-calling the
+   * constructor.
    */
   void Clear()
   {
-    PL_DHashTableEnumerate(&mTable, PL_DHashStubEnumRemove, nullptr);
+    mTable.Clear();
   }
 
   /**
    * client must provide a <code>SizeOfEntryExcludingThisFun</code> function for
    *   SizeOfExcludingThis.
    * @param     aEntry the entry being enumerated
    * @param     mallocSizeOf the function used to measure heap-allocated blocks
    * @param     arg passed unchanged from <code>SizeOf{In,Ex}cludingThis</code>
--- a/xpcom/glue/objs.mozbuild
+++ b/xpcom/glue/objs.mozbuild
@@ -20,17 +20,16 @@ xpcom_glue_src_lcppsrcs = [
     'nsEnumeratorUtils.cpp',
     'nsID.cpp',
     'nsIInterfaceRequestorUtils.cpp',
     'nsINIParser.cpp',
     'nsISupportsImpl.cpp',
     'nsMemory.cpp',
     'nsQuickSort.cpp',
     'nsTArray.cpp',
-    'nsTHashtable.cpp',
     'nsThreadUtils.cpp',
     'nsTObserverArray.cpp',
     'nsVersionComparator.cpp',
     'nsWeakReference.cpp',
     'pldhash.cpp',
 ]
 
 xpcom_glue_src_cppsrcs = [
--- a/xpcom/libxpcomrt/moz.build
+++ b/xpcom/libxpcomrt/moz.build
@@ -72,17 +72,16 @@ xpcom_glue_src = [
     'nsEnumeratorUtils.cpp',
     'GenericFactory.cpp',
     'nsID.cpp',
     'nsISupportsImpl.cpp',
     'nsMemory.cpp',
     'nsProxyRelease.cpp',
     'nsQuickSort.cpp',
     'nsTArray.cpp',
-    'nsTHashtable.cpp',
     'nsTObserverArray.cpp',
     'nsThreadUtils.cpp',
     'nsWeakReference.cpp',
     'pldhash.cpp',
 ]
 src_list += [
     '/xpcom/glue/%s' % s for s in xpcom_glue_src
 ]