refactor(tvix/eval): short-circuit on empty attrs in compiler
This is marginally more efficient and has simpler bytecode. Change-Id: Iad37c9aeef24583e8f696911bcd83d43639f2e36 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7769 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
4e98730f38
commit
61b8a9b2ba
1 changed files with 9 additions and 0 deletions
|
@ -640,6 +640,15 @@ impl Compiler<'_> {
|
|||
self.declare_namespaced_inherits(kind, inherit_froms, &mut bindings);
|
||||
self.declare_bindings(kind, &mut count, &mut bindings, node);
|
||||
|
||||
// Check if we can bail out on empty bindings
|
||||
if count == 0 {
|
||||
// still need an attrset to exist, but it is empty.
|
||||
if kind.is_attrs() {
|
||||
self.emit_constant(Value::Attrs(Box::new(NixAttrs::empty())), node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Actually bind values and ensure they are on the stack.
|
||||
self.bind_values(bindings);
|
||||
|
||||
|
|
Loading…
Reference in a new issue