refactor(tvix/eval): add NixAttrs::contains function

This avoids copying around the value more than needed.

Change-Id: I35949d16dad7fb8f76e0f641eaccf48322144777
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6263
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-08-24 18:31:43 +03:00 committed by tazjin
parent 86b21f9c33
commit c3b13416b0
2 changed files with 13 additions and 1 deletions

View file

@ -242,7 +242,7 @@ impl VM {
OpCode::OpAttrsIsSet => {
let key = self.pop().to_string()?;
let result = match self.pop() {
Value::Attrs(attrs) => attrs.select(key.as_str()).is_some(),
Value::Attrs(attrs) => attrs.contains(key.as_str()),
// Nix allows use of `?` on non-set types, but
// always returns false in those cases.