Bug 807713 - add warning comment for nsTObserverArray::ElementAt. r=sicking

This commit is contained in:
Andrew McCreight 2012-11-23 10:50:05 -08:00
parent a84cff7a7d
commit 0beff55dae
2 changed files with 7 additions and 12 deletions

View File

@ -61,7 +61,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsAccessiblePivot)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPosition)
uint32_t i, length = tmp->mObservers.Length();
for (i = 0; i < length; ++i) {
cb.NoteXPCOMChild(tmp->mObservers[i]);
cb.NoteXPCOMChild(tmp->mObservers.ElementAt(i));
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

View File

@ -92,7 +92,8 @@ class nsAutoTObserverArray : protected nsTObserverArray_base {
}
// This method provides direct access to the i'th element of the array.
// The given index must be within the array bounds.
// The given index must be within the array bounds. If the underlying array
// may change during iteration, use an iterator instead of this function.
// @param i The index of an element in the array.
// @return A reference to the i'th element of the array.
elem_type& ElementAt(index_type i) {
@ -118,15 +119,9 @@ class nsAutoTObserverArray : protected nsTObserverArray_base {
return mArray.SafeElementAt(i, def);
}
// Shorthand for ElementAt(i)
elem_type& operator[](index_type i) {
return ElementAt(i);
}
// Shorthand for ElementAt(i)
const elem_type& operator[](index_type i) const {
return ElementAt(i);
}
// No operator[] is provided because the point of this class is to support
// allow modifying the array during iteration, and ElementAt() is not safe
// in those conditions.
//
// Search methods
@ -392,7 +387,7 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
aFlags |= CycleCollectionEdgeNameArrayFlag;
size_t length = aField.Length();
for (size_t i = 0; i < length; ++i) {
ImplCycleCollectionTraverse(aCallback, aField[i], aName, aFlags);
ImplCycleCollectionTraverse(aCallback, aField.ElementAt(i), aName, aFlags);
}
}