mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
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.
This commit is contained in:
parent
1ef48f39c5
commit
ea80354c08
@ -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;
|
||||
}
|
@ -19,13 +19,6 @@
|
||||
|
||||
#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.
|
||||
*
|
||||
@ -211,11 +204,13 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,6 @@ xpcom_glue_src_lcppsrcs = [
|
||||
'nsMemory.cpp',
|
||||
'nsQuickSort.cpp',
|
||||
'nsTArray.cpp',
|
||||
'nsTHashtable.cpp',
|
||||
'nsThreadUtils.cpp',
|
||||
'nsTObserverArray.cpp',
|
||||
'nsVersionComparator.cpp',
|
||||
|
@ -77,7 +77,6 @@ xpcom_glue_src = [
|
||||
'nsProxyRelease.cpp',
|
||||
'nsQuickSort.cpp',
|
||||
'nsTArray.cpp',
|
||||
'nsTHashtable.cpp',
|
||||
'nsTObserverArray.cpp',
|
||||
'nsThreadUtils.cpp',
|
||||
'nsWeakReference.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user