Bug 1606568 - Add JS::ConstLatin1Chars. r=jwalden
authorPhilip Chimento <philip.chimento@gmail.com>
Wed, 22 Jul 2020 02:53:49 +0000
changeset 541558 eefb0b6651d78a77e2988424819516e6594a9fa8
parent 541557 bc83536b5d52cf835e89a4d1782ea3d44440fca3
child 541559 18a0675bd755d8bad9a5825e43f94294f4375da9
push id122334
push usercsabou@mozilla.com
push dateWed, 22 Jul 2020 03:23:22 +0000
treeherderautoland@eefb0b6651d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1606568
milestone80.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 1606568 - Add JS::ConstLatin1Chars. r=jwalden Useful for the public BigInt API which takes Range<const CharT>. Allows JS::NumberToBigInt(JSContext*, JS::ConstLatin1Chars) in order to match JS::NumberToBigInt(JSContext*, JS::ConstTwoByteChars) which already exists. Differential Revision: https://phabricator.services.mozilla.com/D82797
js/public/CharacterEncoding.h
--- a/js/public/CharacterEncoding.h
+++ b/js/public/CharacterEncoding.h
@@ -36,16 +36,30 @@ class Latin1Chars : public mozilla::Rang
   Latin1Chars(const Latin1Char* aBytes, size_t aLength)
       : Base(const_cast<Latin1Char*>(aBytes), aLength) {}
   Latin1Chars(const char* aBytes, size_t aLength)
       : Base(reinterpret_cast<Latin1Char*>(const_cast<char*>(aBytes)),
              aLength) {}
 };
 
 /*
+ * Like Latin1Chars, but the chars are const.
+ */
+class ConstLatin1Chars : public mozilla::Range<const Latin1Char> {
+  typedef mozilla::Range<const Latin1Char> Base;
+
+ public:
+  using CharT = Latin1Char;
+
+  ConstLatin1Chars() = default;
+  ConstLatin1Chars(const Latin1Char* aChars, size_t aLength)
+      : Base(aChars, aLength) {}
+};
+
+/*
  * A Latin1Chars, but with \0 termination for C compatibility.
  */
 class Latin1CharsZ : public mozilla::RangedPtr<Latin1Char> {
   typedef mozilla::RangedPtr<Latin1Char> Base;
 
  public:
   using CharT = Latin1Char;