Use interned strings for AST nodes.

This commit is contained in:
Stephen Chung
2022-08-13 18:07:42 +08:00
parent 1c7b80ed13
commit 28743594d0
11 changed files with 147 additions and 205 deletions

View File

@@ -1,6 +1,6 @@
//! Module defining script identifiers.
use crate::{Identifier, Position};
use crate::{ImmutableString, Position};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{
@@ -14,7 +14,7 @@ use std::{
#[derive(Clone, Eq, PartialEq, Hash)]
pub struct Ident {
/// Identifier name.
pub name: Identifier,
pub name: ImmutableString,
/// Position.
pub pos: Position,
}
@@ -34,7 +34,7 @@ impl AsRef<str> for Ident {
}
impl Deref for Ident {
type Target = Identifier;
type Target = ImmutableString;
#[inline(always)]
fn deref(&self) -> &Self::Target {
@@ -50,12 +50,6 @@ impl DerefMut for Ident {
}
impl Ident {
/// An empty [`Ident`].
pub const EMPTY: Self = Self {
name: Identifier::new_const(),
pos: Position::NONE,
};
/// Get the name of the identifier as a string slice.
#[inline(always)]
#[must_use]