From e00cfa2c2e8bcdba946c400f7817fdfcbe60b144 Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Mon, 12 Jun 2017 23:11:37 +0200 Subject: [PATCH] Speedup jid parsing name control ns/iter variable ns/iter diff ns/iter diff % speedup big_jids 638 456 -182 -28.53% x 1.40 small_jids 92 91 -1 -1.09% x 1.01 --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5ced4003..3f39cbcf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,7 +76,7 @@ impl FromStr for Jid { fn from_str(s: &str) -> Result { // TODO: very naive, may need to do it differently let iter = s.chars(); - let mut buf = String::new(); + let mut buf = String::with_capacity(s.len()); let mut state = ParserState::Node; let mut node = None; let mut domain = None;