diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /js/public/StableStringChars.h | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/public/StableStringChars.h')
-rw-r--r-- | js/public/StableStringChars.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/js/public/StableStringChars.h b/js/public/StableStringChars.h index 5c50df18cb..84429041da 100644 --- a/js/public/StableStringChars.h +++ b/js/public/StableStringChars.h @@ -53,10 +53,15 @@ class MOZ_STACK_CLASS JS_PUBLIC_API AutoStableStringChars final { const char16_t* twoByteChars_; const Latin1Char* latin1Chars_; }; + MOZ_INIT_OUTSIDE_CTOR uint32_t length_; mozilla::Maybe<js::Vector<uint8_t, InlineCapacity>> ownChars_; enum State { Uninitialized, Latin1, TwoByte }; State state_; + // Prevent the string that owns s's chars from being collected (by storing it + // in s_) or deduplicated. + void holdStableChars(JSLinearString* s); + public: explicit AutoStableStringChars(JSContext* cx) : s_(cx), state_(Uninitialized) {} @@ -99,7 +104,10 @@ class MOZ_STACK_CLASS JS_PUBLIC_API AutoStableStringChars final { return true; } - size_t length() const { return GetStringLength(s_); } + size_t length() const { + MOZ_ASSERT(state_ != Uninitialized); + return length_; + } private: AutoStableStringChars(const AutoStableStringChars& other) = delete; |