pub struct StringOptimizer { /* private fields */ }Expand description
Analyzes string usage patterns to determine optimal string types
Implementations§
Source§impl StringOptimizer
impl StringOptimizer
pub fn new() -> StringOptimizer
Sourcepub fn analyze_function(&mut self, func: &HirFunction)
pub fn analyze_function(&mut self, func: &HirFunction)
Analyze a function to determine optimal string types
Sourcepub fn get_optimal_type(&self, context: &StringContext) -> OptimalStringType
pub fn get_optimal_type(&self, context: &StringContext) -> OptimalStringType
Get the optimal string type for a given context
Sourcepub fn finalize_interned_names(&mut self)
pub fn finalize_interned_names(&mut self)
Finalize interned string names, resolving any collisions This must be called after analysis and before code generation
Sourcepub fn should_intern(&self, s: &str) -> bool
pub fn should_intern(&self, s: &str) -> bool
Check if a string literal should be interned
Sourcepub fn get_interned_name(&self, s: &str) -> Option<String>
pub fn get_interned_name(&self, s: &str) -> Option<String>
Get interned string name for a literal Returns the unique constant name for an interned string
Sourcepub fn generate_interned_constants(&self) -> Vec<String>
pub fn generate_interned_constants(&self) -> Vec<String>
Generate interned string constants
Trait Implementations§
Source§impl Debug for StringOptimizer
impl Debug for StringOptimizer
Source§impl Default for StringOptimizer
impl Default for StringOptimizer
Source§fn default() -> StringOptimizer
fn default() -> StringOptimizer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StringOptimizer
impl RefUnwindSafe for StringOptimizer
impl Send for StringOptimizer
impl Sync for StringOptimizer
impl Unpin for StringOptimizer
impl UnwindSafe for StringOptimizer
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more