Always validate performance changes through profiling or benchmarking before implementation, and favor memory-efficient patterns when making optimizations. Key practices:
Always validate performance changes through profiling or benchmarking before implementation, and favor memory-efficient patterns when making optimizations. Key practices:
// Before changing buffer sizes, validate impact:
const SCROLLBACK_LEN: usize = 1024;
// Profile current performance
// Test new value
const SCROLLBACK_LEN: usize = 2048;
// Validate no significant regression
&str
over &String
to avoid double indirectionlet mut map = HashMap::with_capacity(items.len());
// Instead of
pub fn get_items(&self) -> Vec<String> {
self.items.iter().map(|i| i.to_string()).collect()
}
// Prefer
pub fn get_items(&self) -> impl Iterator<Item = &str> + '_ {
self.items.iter().map(|i| i.as_str())
}
Enter the URL of a public GitHub repository