Skip to content

Commit

Permalink
perf: Default buffer size
Browse files Browse the repository at this point in the history
Can always use `render_to` if this is too large.
  • Loading branch information
epage committed Nov 20, 2018
1 parent 2bc2462 commit 58eec66
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pub struct Template {
impl Template {
/// Renders an instance of the Template, using the given globals.
pub fn render(&self, globals: &interpreter::Globals) -> Result<String> {
let mut data = Vec::new();
const BEST_GUESS: usize = 10_000;
let mut data = Vec::with_capacity(BEST_GUESS);
self.render_to(&mut data, globals)?;
Ok(String::from_utf8(data).expect("render only writes UTF-8"))
}
Expand Down

0 comments on commit 58eec66

Please sign in to comment.