summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-06-19 21:32:21 +0200
committerpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-06-19 21:35:08 +0200
commit1f6716412b0d6543db98c68fc5280d019f8a2fdb (patch)
tree5dca7a747ff1185ffce3c43e36e6a845d638c3f7 /src
parentd1bfd8cf0c1db4a1d5d1dd8955496262b7e7d8ee (diff)
Added a small performance boost, valuable when printing really big
tables
Diffstat (limited to 'src')
-rw-r--r--src/cell.rs5
-rw-r--r--src/format.rs4
-rw-r--r--src/main.rs1
3 files changed, 2 insertions, 8 deletions
diff --git a/src/cell.rs b/src/cell.rs
index b3caacf..203886d 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -55,10 +55,7 @@ impl Cell {
try!(out.write_all(content.as_bytes()));
len = content.len();
}
- try!(out.write_all(b" "));
- for _ in 0..(col_width - len) {
- try!(out.write_all(b" "));
- }
+ try!(out.write_all(&vec![' ' as u8; col_width - len + 1]));
return Ok(());
}
}
diff --git a/src/format.rs b/src/format.rs
index c9ac29a..2ccb02a 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -23,9 +23,7 @@ impl LineSeparator {
pub fn print<T: Write>(&self, out: &mut T, col_width: &[usize]) -> Result<(), Error> {
try!(out.write_all(&self.cross));
for width in col_width {
- for _ in 0..(width + 2) {
- try!(out.write_all(&self.line));
- }
+ try!(out.write_all(&vec![self.line[0]; width+2]));
try!(out.write_all(&self.cross));
}
return out.write_all(LINEFEED);
diff --git a/src/main.rs b/src/main.rs
index 0096b5d..3a0bdd2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -26,5 +26,4 @@ fn main() {
table.set_format(FORMAT_DEFAULT);
table.printstd();
println!("{:?}", table);
-
}