diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-12-07 08:30:28 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-12-07 08:30:28 -0500 |
commit | 03a6fe754172bf780fb854dcd693128c86caa53b (patch) | |
tree | fa94ca269c983e243ae08e8e3631b9b0c3e8a257 /src | |
parent | 2234ccb9cde70d9b9fcc26a85523ffc97e3bebc6 (diff) | |
download | vt100-rust-03a6fe754172bf780fb854dcd693128c86caa53b.tar.gz vt100-rust-03a6fe754172bf780fb854dcd693128c86caa53b.zip |
try to micro-optimize getting cell contents a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/cell.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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::<String>() + 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. |