Use SmartString inside ImmutableString.

This commit is contained in:
Stephen Chung
2021-04-23 19:10:10 +08:00
parent fc782c5563
commit 335ab64a2c
3 changed files with 53 additions and 65 deletions

View File

@@ -140,11 +140,11 @@ pub use utils::ImmutableString;
/// An identifier in Rhai. [`SmartString`](https://crates.io/crates/smartstring) is used because most
/// identifiers are ASCII and short, fewer than 23 characters, so they can be stored inline.
#[cfg(not(feature = "no_smartstring"))]
pub type Identifier = smartstring::SmartString<smartstring::Compact>;
#[cfg(not(feature = "no_smartstring_for_identifier"))]
pub type Identifier = SmartString;
/// An identifier in Rhai.
#[cfg(feature = "no_smartstring")]
#[cfg(feature = "no_smartstring_for_identifier")]
pub type Identifier = ImmutableString;
/// A trait to enable registering Rust functions.
@@ -305,6 +305,12 @@ type StaticVec<T> = smallvec::SmallVec<[T; 4]>;
#[cfg(feature = "internals")]
pub type StaticVec<T> = smallvec::SmallVec<[T; 4]>;
#[cfg(not(feature = "internals"))]
pub(crate) type SmartString = smartstring::SmartString<smartstring::Compact>;
#[cfg(feature = "internals")]
pub type SmartString = smartstring::SmartString<smartstring::Compact>;
// Compiler guards against mutually-exclusive feature flags
#[cfg(feature = "no_float")]