summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wast/src/parser.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /third_party/rust/wast/src/parser.rs
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--third_party/rust/wast/src/parser.rs12
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.