tamer: asg::graph::xmli::TokenStack::push_all: New method
Rust optimizes away the iterator and array, compiling into separate `push` calls as before. DEV-13708main
parent
9990be58a7
commit
d078b24efd
|
@ -101,9 +101,11 @@ impl<'a> ParseState for AsgTreeToXirf<'a> {
|
|||
Object::Pkg(pkg) => {
|
||||
let span = pkg.span();
|
||||
|
||||
toks.push(ns(QN_XMLNS_T, URI_LV_TPL, span));
|
||||
toks.push(ns(QN_XMLNS_C, URI_LV_CALC, span));
|
||||
toks.push(ns(QN_XMLNS, URI_LV_RATER, span));
|
||||
toks.push_all([
|
||||
ns(QN_XMLNS_T, URI_LV_TPL, span),
|
||||
ns(QN_XMLNS_C, URI_LV_CALC, span),
|
||||
ns(QN_XMLNS, URI_LV_RATER, span),
|
||||
]);
|
||||
|
||||
Transition(self).ok(package(pkg, depth))
|
||||
}
|
||||
|
@ -243,20 +245,17 @@ struct TokenStack(ArrayVec<Xirf, TOK_STACK_SIZE>);
|
|||
|
||||
impl TokenStack {
|
||||
fn push(&mut self, tok: Xirf) {
|
||||
match self {
|
||||
Self(stack) => {
|
||||
if stack.is_full() {
|
||||
diagnostic_panic!(
|
||||
vec![tok.internal_error(
|
||||
"while emitting a token for this object"
|
||||
)],
|
||||
"token stack exhausted (increase TOK_STACK_SIZE)",
|
||||
)
|
||||
}
|
||||
let Self(stack) = self;
|
||||
|
||||
stack.push(tok)
|
||||
}
|
||||
if stack.is_full() {
|
||||
diagnostic_panic!(
|
||||
vec![tok
|
||||
.internal_error("while emitting a token for this object")],
|
||||
"token stack exhausted (increase TOK_STACK_SIZE)",
|
||||
)
|
||||
}
|
||||
|
||||
stack.push(tok)
|
||||
}
|
||||
|
||||
fn pop(&mut self) -> Option<Xirf> {
|
||||
|
@ -270,6 +269,10 @@ impl TokenStack {
|
|||
Self(stack) => stack.is_empty(),
|
||||
}
|
||||
}
|
||||
|
||||
fn push_all(&mut self, toks: impl IntoIterator<Item = Xirf>) {
|
||||
toks.into_iter().for_each(|x| self.push(x))
|
||||
}
|
||||
}
|
||||
|
||||
// System tests covering this functionality can be found in
|
||||
|
|
Loading…
Reference in New Issue