implement nsTObserverArray using nsTArray, clean up the interface, provide an nsAutoTObserverArray, and use it to reduce allocations in nsEventListenerManager. b=407442, r+sr=sicking, a=beltzner

This commit is contained in:
2007-12-18 17:06:34 -08:00
parent aea34c636c
commit ec4d8e5431
16 changed files with 367 additions and 267 deletions

View File

@@ -20,6 +20,7 @@
*
* Contributor(s):
* Jonas Sicking <jonas@sicking.cc> (Original Author)
* Daniel Witte <dwitte@stanford.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -38,15 +39,13 @@
#include "nsTObserverArray.h"
void
nsTObserverArray_base::AdjustIterators(PRInt32 aModPos,
PRInt32 aAdjustment)
nsTObserverArray_base::AdjustIterators(index_type aModPos,
diff_type aAdjustment)
{
NS_PRECONDITION(aAdjustment == -1 || aAdjustment == 1,
"invalid adjustment");
Iterator_base* iter = mIterators;
while (iter) {
NS_ASSERTION(&(iter->mArray) == this, "wrong array");
if (iter->mPosition > aModPos) {
iter->mPosition += aAdjustment;
}
@@ -55,14 +54,10 @@ nsTObserverArray_base::AdjustIterators(PRInt32 aModPos,
}
void
nsTObserverArray_base::Clear()
nsTObserverArray_base::ClearIterators()
{
mObservers.Clear();
Iterator_base* iter = mIterators;
while (iter) {
NS_ASSERTION(&(iter->mArray) == this, "wrong array");
iter->mPosition = 0;
iter = iter->mNext;
}