commit fe844886140cdbd15685dcfcf0cb62f2f0d23b1f
parent bc765dc91b6e8bb02fa141e39e4c3d2530ba0e08
Author: William Casarin <jb55@jb55.com>
Date: Mon, 3 Jul 2023 10:00:18 -0700
shards: have some default initial capacity
So we don't have to heap allocate needlessly
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/shard.rs b/src/shard.rs
@@ -40,7 +40,8 @@ struct Shards {
impl Shards {
fn new() -> Shards {
Shards {
- shards: vec![],
+ // some initial capacity so we don't have to allocate on small parses
+ shards: Vec::with_capacity(32),
num_words: 0,
}
}