From 03a6fe754172bf780fb854dcd693128c86caa53b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 7 Dec 2019 08:30:28 -0500 Subject: try to micro-optimize getting cell contents a bit --- src/cell.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cell.rs b/src/cell.rs index 45e795b..95d047e 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -64,7 +64,11 @@ impl Cell { /// used, but will contain at most one character with a non-zero character /// width. pub fn contents(&self) -> String { - self.contents.iter().take(self.len()).collect::() + let mut s = String::with_capacity(CODEPOINTS_IN_CELL * 4); + for c in self.contents.iter().take(self.len()) { + s.push(*c); + } + s } /// Returns whether the cell contains any text data. -- cgit v1.2.3