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 committed 2019-02-22 21:14:37 -08:00
1 parent 983eca1209
commit a022d3856a
1 file changed
+3 -1
+3 -1
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);