pub struct ReferenceOptimizer { /* private fields */ }Expand description
Reference optimizer
Implementations§
Source§impl ReferenceOptimizer
impl ReferenceOptimizer
pub fn new() -> Self
Sourcepub fn track_read(&mut self, var: &str)
pub fn track_read(&mut self, var: &str)
Track variable read
Sourcepub fn track_write(&mut self, var: &str)
pub fn track_write(&mut self, var: &str)
Track variable write
Sourcepub fn track_move(&mut self, var: &str)
pub fn track_move(&mut self, var: &str)
Track variable move
Sourcepub fn track_borrow(&mut self, var: &str, mutable: bool)
pub fn track_borrow(&mut self, var: &str, mutable: bool)
Track variable borrow
Sourcepub fn optimize_parameter(
&mut self,
param_name: &str,
param_type: &str,
usage_in_body: &str,
) -> String
pub fn optimize_parameter( &mut self, param_name: &str, param_type: &str, usage_in_body: &str, ) -> String
Analyze function parameter and suggest optimization
Sourcepub fn optimize_string(
&mut self,
var_name: &str,
value: &str,
is_literal: bool,
) -> String
pub fn optimize_string( &mut self, var_name: &str, value: &str, is_literal: bool, ) -> String
Optimize string usage
Sourcepub fn eliminate_clone(&mut self, var_name: &str, expr: &str) -> String
pub fn eliminate_clone(&mut self, var_name: &str, expr: &str) -> String
Detect and eliminate unnecessary clones
Sourcepub fn optimize_iterator(&mut self, location: &str, code: &str) -> String
pub fn optimize_iterator(&mut self, location: &str, code: &str) -> String
Optimize iterator chains to avoid intermediate collections
Sourcepub fn optimize_return(
&mut self,
func_name: &str,
return_type: &str,
returns_local: bool,
) -> String
pub fn optimize_return( &mut self, func_name: &str, return_type: &str, returns_local: bool, ) -> String
Optimize return type to use reference when possible
Sourcepub fn suggest_cow(
&mut self,
var_name: &str,
sometimes_owned: bool,
sometimes_borrowed: bool,
) -> String
pub fn suggest_cow( &mut self, var_name: &str, sometimes_owned: bool, sometimes_borrowed: bool, ) -> String
Suggest Cow for conditional ownership
Sourcepub fn optimize_smart_pointer(
&mut self,
var_name: &str,
is_shared: bool,
is_mutable: bool,
is_threadsafe: bool,
) -> String
pub fn optimize_smart_pointer( &mut self, var_name: &str, is_shared: bool, is_mutable: bool, is_threadsafe: bool, ) -> String
Optimize smart pointer usage
Sourcepub fn get_optimizations(&self) -> &[Optimization]
pub fn get_optimizations(&self) -> &[Optimization]
Get all optimizations found
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ReferenceOptimizer
impl RefUnwindSafe for ReferenceOptimizer
impl Send for ReferenceOptimizer
impl Sync for ReferenceOptimizer
impl Unpin for ReferenceOptimizer
impl UnsafeUnpin for ReferenceOptimizer
impl UnwindSafe for ReferenceOptimizer
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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