Bug 767141 - Add a handleAt(i) accessor to AutoVectorRooter. r=bhackett
authorSteve Fink <sfink@mozilla.com>
Thu, 21 Jun 2012 14:18:02 -0700
changeset 98015 54bb503183ebfcc0c98faa89c097a128eabd155c
parent 98014 0d87f9f5d3c6053a3ded26d1a316897557e5aa04
child 98016 0dd9559f15ff98a990e79cb204f76a1c88a72d8a
push id11322
push usersfink@mozilla.com
push dateSat, 30 Jun 2012 04:47:50 +0000
treeherdermozilla-inbound@8f15e352d4b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs767141
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 767141 - Add a handleAt(i) accessor to AutoVectorRooter. r=bhackett Given that AutoVectorRooter roots a vector of gcthings, it seems convenient to be able to access elements for passing into Handle-accepting functions without re-rooting.
js/src/jsapi.h
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1160,16 +1160,18 @@ class AutoVectorRooter : protected AutoG
 
     bool reserve(size_t newLength) {
         return vector.reserve(newLength);
     }
 
     T &operator[](size_t i) { return vector[i]; }
     const T &operator[](size_t i) const { return vector[i]; }
 
+    JS::Handle<T> handleAt(size_t i) const { return JS::Handle<T>::fromMarkedLocation(&vector[i]); }
+
     const T *begin() const { return vector.begin(); }
     T *begin() { return vector.begin(); }
 
     const T *end() const { return vector.end(); }
     T *end() { return vector.end(); }
 
     const T &back() const { return vector.back(); }