summaryrefslogtreecommitdiffstats
path: root/xpcom/glue
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@wolfbeast.com>2019-03-14 15:21:42 +0100
committerGitHub <noreply@github.com>2019-03-14 15:21:42 +0100
commit91cbd86a5e0e851904015fc98f3b4bb4422e584b (patch)
tree603ad2d101065a622db1d02c0f0603a0fdfcea51 /xpcom/glue
parentd791dfed61bbc963351e5965657a3b13d4e6dceb (diff)
parent0ff4dbff80ddea637b0fb02c885e222ddcfa171a (diff)
downloadUXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar
UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar.gz
UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar.lz
UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar.xz
UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.zip
Merge pull request #1002 from JustOff/PR_URLSearchParams
Align URLSearchParams with the spec
Diffstat (limited to 'xpcom/glue')
-rw-r--r--xpcom/glue/nsTArray.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h
index 82586a79a..64af17bbb 100644
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -1503,6 +1503,24 @@ public:
mozilla::Forward<Item>(aItem));
}
+ // Reconstruct the element at the given index, and return a pointer to the
+ // reconstructed element. This will destroy the existing element and
+ // default-construct a new one, giving you a state much like what single-arg
+ // InsertElementAt(), or no-arg AppendElement() does, but without changing the
+ // length of the array.
+ //
+ // array[idx] = T()
+ //
+ // would accomplish the same thing as long as T has the appropriate moving
+ // operator=, but some types don't for various reasons.
+ elem_type* ReconstructElementAt(index_type aIndex)
+ {
+ elem_type* elem = &ElementAt(aIndex);
+ elem_traits::Destruct(elem);
+ elem_traits::Construct(elem);
+ return elem;
+ }
+
// This method searches for the smallest index of an element that is strictly
// greater than |aItem|. If |aItem| is inserted at this index, the array will
// remain sorted and |aItem| would come after all elements that are equal to