Removed unnecessary mallocs.
The colored crate was being used for convinient coloring of the terminal text, but after profiling I found it was responsible for almost 1/3 of the memory allocations of the jisho searching feature. Decided to write ANSI codes manually instead, along with using write! + format_args! instead of format! for similar reasons, but not as egregious.
This commit is contained in:
parent
a475790e63
commit
6fcd5489d5
5 changed files with 73 additions and 70 deletions
|
@ -3,7 +3,6 @@ use std::{
|
|||
collections::HashSet,
|
||||
};
|
||||
|
||||
use colored::*;
|
||||
use kradical_parsing::radk;
|
||||
|
||||
pub fn search_by_radical(query: &mut String, radk_list: &[radk::Membership]) -> Option<()> {
|
||||
|
@ -105,7 +104,7 @@ fn search_by_strokes(query: &mut String, radk_list: &[radk::Membership], n: usiz
|
|||
char_and_index.0 +
|
||||
char_and_index.1.len_utf8(),
|
||||
rad.to_string().as_str());
|
||||
println!("{}", query.as_str().bright_black());
|
||||
println!("\x1b[90m{}\x1b[m", query);
|
||||
return Some(*rad);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue