Bug 1606568 - Add JS::ConstLatin1Chars. r=jwalden
☠☠ backed out by 5f9a6b8dc5f2 ☠ ☠
authorPhilip Chimento <philip.chimento@gmail.com>
Mon, 20 Jul 2020 23:58:27 +0000
changeset 541384 747640138ffbc0d07ee160cfbeb59a332b3b96b9
parent 541383 a8dac56d2df2c603db3e05f1988988bb84067a0f
child 541385 835cceddaf49cc50d48181431cfdd2e2e76b147b
push id122209
push userbtara@mozilla.com
push dateTue, 21 Jul 2020 01:08:16 +0000
treeherderautoland@747640138ffb [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;