diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-09 09:34:26 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-09 14:58:57 -0500 |
commit | 1df95eca71e5f2a9cb9adb2995a7552ec980dc8b (patch) | |
tree | 28611bcc57d3b9a79273204e50db2c54c8cfebf9 | |
parent | 4e774bc93fc9aaa1f84db7736cd45eef71e712cc (diff) | |
download | vt100-rust-1df95eca71e5f2a9cb9adb2995a7552ec980dc8b.tar.gz vt100-rust-1df95eca71e5f2a9cb9adb2995a7552ec980dc8b.zip |
another micro-optimization
-rw-r--r-- | src/cell.rs | 6 | ||||
-rw-r--r-- | 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; |