1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 15:04:36 +03:00

micro optimize setting up the storage length

SmallVec::resize showed up as a hot spot in the profiler
This commit is contained in:
Wez Furlong 2019-02-22 21:14:37 -08:00
parent 983eca1209
commit a022d3856a

View File

@ -225,7 +225,9 @@ impl Cell {
pub fn new(text: char, attrs: CellAttributes) -> Self {
let len = text.len_utf8();
let mut storage = SmallVec::with_capacity(len);
storage.resize(len, 0);
unsafe {
storage.set_len(len);
}
text.encode_utf8(&mut storage);
Self::nerf_control_char(&mut storage);