feat: hashmap with_capacity

This commit is contained in:
2025-05-17 20:04:12 +08:00
parent 7b55a15281
commit ec61eaa140
4 changed files with 16 additions and 10 deletions

View File

@@ -97,7 +97,7 @@ impl Compile for ir::Thunk {
impl Compile for ir::Attrs {
fn compile(self, comp: &mut Compiler) {
comp.push(OpCode::AttrSet);
comp.push(OpCode::AttrSet { cap: self.stcs.len() + self.dyns.len() });
for stc in self.stcs {
stc.1.compile(comp);
if !self.rec {
@@ -250,17 +250,17 @@ impl Compile for ir::HasAttr {
for attr in self.rhs {
match attr {
ir::Attr::Str(sym) => {
comp.push(OpCode::AttrSet);
comp.push(OpCode::AttrSet { cap: 0 });
comp.push(OpCode::SelectOrDefault { sym })
}
ir::Attr::Dynamic(dynamic) => {
dynamic.compile(comp);
comp.push(OpCode::AttrSet);
comp.push(OpCode::AttrSet { cap: 0 });
comp.push(OpCode::SelectDynamicOrDefault);
}
ir::Attr::Strs(string) => {
string.compile(comp);
comp.push(OpCode::AttrSet);
comp.push(OpCode::AttrSet { cap: 0 });
comp.push(OpCode::SelectDynamicOrDefault);
}
}
@@ -281,17 +281,17 @@ impl Compile for ir::Select {
for attr in self.attrpath {
match attr {
ir::Attr::Str(sym) => {
comp.push(OpCode::AttrSet);
comp.push(OpCode::AttrSet { cap: 0 });
comp.push(OpCode::SelectOrDefault { sym })
}
ir::Attr::Dynamic(dynamic) => {
dynamic.compile(comp);
comp.push(OpCode::AttrSet);
comp.push(OpCode::AttrSet { cap: 0 });
comp.push(OpCode::SelectDynamicOrDefault);
}
ir::Attr::Strs(string) => {
string.compile(comp);
comp.push(OpCode::AttrSet);
comp.push(OpCode::AttrSet { cap: 0 });
comp.push(OpCode::SelectDynamicOrDefault);
}
}