#[repr(transparent)]pub struct StringId(pub u32);Expand description
Re-export StringId from shape-value — the canonical definition.
A string pool identifier. Indexes into BytecodeProgram::strings.
Using StringId instead of a heap-allocated String makes
Operand (and therefore Instruction) Copy.
§Current status
StringId is used by bytecode instructions (Operand) to reference interned strings
in BytecodeProgram::strings, and it is fully integrated with the bytecode compiler
and VM executor. However, many runtime paths (e.g. HeapValue::String, method dispatch
keys, and serialization) still use Arc<String> rather than intern IDs. A crate-level
InternPool that maps StringId <-> &str would allow these paths to avoid heap
allocation and use O(1) integer comparison instead of string comparison.
TODO: Evaluate adding an InternPool struct here (owned by the VM or compilation
context) that bridges the gap between StringId in opcodes and Arc<String> in
HeapValue. Key considerations:
- The pool must be thread-safe if shared across async tasks.
HeapValue::Stringcould holdStringIdinstead ofArc<String>for short strings.- Method registry PHF keys could use
StringIdfor faster dispatch.
Tuple Fields§
§0: u32Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for StringId
impl<'de> Deserialize<'de> for StringId
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StringId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StringId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for StringId
impl Ord for StringId
Source§impl PartialOrd for StringId
impl PartialOrd for StringId
Source§impl Serialize for StringId
impl Serialize for StringId
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for StringId
impl Eq for StringId
impl StructuralPartialEq for StringId
Auto Trait Implementations§
impl Freeze for StringId
impl RefUnwindSafe for StringId
impl Send for StringId
impl Sync for StringId
impl Unpin for StringId
impl UnsafeUnpin for StringId
impl UnwindSafe for StringId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.