Use more const functions.

This commit is contained in:
Stephen Chung
2021-11-27 14:24:06 +08:00
parent 280b5b405e
commit abe6b4a29b
7 changed files with 19 additions and 14 deletions

View File

@@ -57,13 +57,18 @@ pub struct IdentifierBuilder(
impl IdentifierBuilder {
/// Create a new IdentifierBuilder.
#[cfg(not(feature = "no_smartstring"))]
#[inline]
#[must_use]
pub const fn new() -> Self {
Self()
}
/// Create a new IdentifierBuilder.
#[cfg(feature = "no_smartstring")]
#[inline]
#[must_use]
pub fn new() -> Self {
Self(
#[cfg(feature = "no_smartstring")]
std::collections::BTreeSet::new(),
)
Self(std::collections::BTreeSet::new())
}
/// Get an identifier from a text string.
#[inline]
@@ -2013,8 +2018,8 @@ fn parse_custom_syntax(
if syntax.scope_may_be_changed {
// Add a barrier variable to the stack so earlier variables will not be matched.
// Variable searches stop at the first barrier.
let empty = state.get_identifier(SCOPE_SEARCH_BARRIER_MARKER);
state.stack.push((empty, AccessMode::ReadWrite));
let marker = state.get_identifier(SCOPE_SEARCH_BARRIER_MARKER);
state.stack.push((marker, AccessMode::ReadWrite));
}
let parse_func = syntax.parse.as_ref();