git.delta.rocks / jrsonnet / refs/commits / 7420435452f0

difftreelog

perf(evaluator) specify known initial capacity

Лач2020-06-10parent: #2bdb11e.patch.diff
in: master

1 file changed

modifiedcrates/jsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
65 }65 }
6666
67 pub fn with_var(&self, name: String, value: Val) -> Result<Context> {67 pub fn with_var(&self, name: String, value: Val) -> Result<Context> {
68 let mut new_bindings = HashMap::new();68 let mut new_bindings = HashMap::with_capacity(1);
69 new_bindings.insert(name, resolved_lazy_val!(value));69 new_bindings.insert(name, resolved_lazy_val!(value));
70 self.extend(new_bindings, None, None, None)70 self.extend(new_bindings, None, None, None)
71 }71 }
101 ) -> Result<Context> {101 ) -> Result<Context> {
102 let this = new_this.or_else(|| self.0.this.clone());102 let this = new_this.or_else(|| self.0.this.clone());
103 let super_obj = new_super_obj.or_else(|| self.0.super_obj.clone());103 let super_obj = new_super_obj.or_else(|| self.0.super_obj.clone());
104 let mut new = HashMap::new();104 let mut new = HashMap::with_capacity(new_bindings.len());
105 for (k, v) in new_bindings.into_iter() {105 for (k, v) in new_bindings.into_iter() {
106 new.insert(k, v.evaluate(this.clone(), super_obj.clone())?);106 new.insert(k, v.evaluate(this.clone(), super_obj.clone())?);
107 }107 }