From 1df95eca71e5f2a9cb9adb2995a7552ec980dc8b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 9 Nov 2019 09:34:26 -0500 Subject: another micro-optimization --- src/cell.rs | 6 ++++-- src/screen.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cell.rs b/src/cell.rs index 8d7e32f..d0d6f0c 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -9,8 +9,10 @@ pub struct Cell { } impl Cell { - pub(crate) fn set(&mut self, c: String, a: crate::attrs::Attrs) { - self.contents = c; + pub(crate) fn set(&mut self, c: char, a: crate::attrs::Attrs) { + let mut buf = vec![0; 4]; + c.encode_utf8(&mut buf); + self.contents = unsafe { String::from_utf8_unchecked(buf) }; self.attrs = a; } diff --git a/src/screen.rs b/src/screen.rs index 4ed065b..05b8935 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -476,7 +476,7 @@ impl Screen { } } } else { - cell.set(c.to_string(), attrs); + cell.set(c, attrs); self.grid_mut().col_inc(1); if width > 1 { let bgcolor = self.attrs.bgcolor; -- cgit v1.2.3-54-g00ecf