diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /third_party/rust/wast/src/parser.rs | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/wast/src/parser.rs')
-rw-r--r-- | third_party/rust/wast/src/parser.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/third_party/rust/wast/src/parser.rs b/third_party/rust/wast/src/parser.rs index 0c85923f83..7a20ebe255 100644 --- a/third_party/rust/wast/src/parser.rs +++ b/third_party/rust/wast/src/parser.rs @@ -65,6 +65,7 @@ use crate::lexer::{Float, Integer, Lexer, Token, TokenKind}; use crate::token::Span; use crate::Error; +use bumpalo::Bump; use std::borrow::Cow; use std::cell::{Cell, RefCell}; use std::collections::HashMap; @@ -303,7 +304,7 @@ pub struct ParseBuffer<'a> { cur: Cell<Position>, known_annotations: RefCell<HashMap<String, usize>>, depth: Cell<usize>, - strings: RefCell<Vec<Box<[u8]>>>, + strings: Bump, } /// The current position within a `Lexer` that we're at. This simultaneously @@ -396,14 +397,7 @@ impl ParseBuffer<'_> { /// This will return a reference to `s`, but one that's safely rooted in the /// `Parser`. fn push_str(&self, s: Vec<u8>) -> &[u8] { - let s = Box::from(s); - let ret = &*s as *const [u8]; - self.strings.borrow_mut().push(s); - // This should be safe in that the address of `ret` isn't changing as - // it's on the heap itself. Additionally the lifetime of this return - // value is tied to the lifetime of `self` (nothing is deallocated - // early), so it should be safe to say the two have the same lifetime. - unsafe { &*ret } + self.strings.alloc_slice_copy(&s) } /// Lexes the next "significant" token from the `pos` specified. |