summaryrefslogtreecommitdiffstats
path: root/xpcom/glue
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-09-11 10:17:37 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-09-11 10:17:37 +0200
commite05705fe54697a43a56c6fcad5053041f3d97ab0 (patch)
treefa1d84a7ae666f163d9669e7026e0411076febbf /xpcom/glue
parent7bf3d2440e8ff65763daedca51aad6d0288ef61d (diff)
downloadUXP-e05705fe54697a43a56c6fcad5053041f3d97ab0.tar
UXP-e05705fe54697a43a56c6fcad5053041f3d97ab0.tar.gz
UXP-e05705fe54697a43a56c6fcad5053041f3d97ab0.tar.lz
UXP-e05705fe54697a43a56c6fcad5053041f3d97ab0.tar.xz
UXP-e05705fe54697a43a56c6fcad5053041f3d97ab0.zip
Replace the custom logic in ObserverList with an nsTObserverArray which has all the necessary logic for stable iteration over a potentially changing list of items.
Diffstat (limited to 'xpcom/glue')
-rw-r--r--xpcom/glue/Observer.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/xpcom/glue/Observer.h b/xpcom/glue/Observer.h
index 958e5e4a9..cf9e507dd 100644
--- a/xpcom/glue/Observer.h
+++ b/xpcom/glue/Observer.h
@@ -7,7 +7,7 @@
#ifndef mozilla_Observer_h
#define mozilla_Observer_h
-#include "nsTArray.h"
+#include "nsTObserverArray.h"
namespace mozilla {
@@ -48,7 +48,7 @@ public:
*/
void AddObserver(Observer<T>* aObserver)
{
- mObservers.AppendElement(aObserver);
+ mObservers.AppendElementUnlessExists(aObserver);
}
/**
@@ -67,15 +67,15 @@ public:
void Broadcast(const T& aParam)
{
- nsTArray<Observer<T>*> observersCopy(mObservers);
- uint32_t size = observersCopy.Length();
- for (uint32_t i = 0; i < size; ++i) {
- observersCopy[i]->Notify(aParam);
+ typename nsTObserverArray<Observer<T>*>::ForwardIterator iter(mObservers);
+ while (iter.HasMore()) {
+ Observer<T>* obs = iter.GetNext();
+ obs->Notify(aParam);
}
}
protected:
- nsTArray<Observer<T>*> mObservers;
+ nsTObserverArray<Observer<T>*> mObservers;
};
} // namespace mozilla