diff options
author | Vincent Ambo <mail@tazj.in> | 2022-12-29T14·34+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-12-29T17·44+0000 |
commit | 86361f0f4a754370b42ae3568ece4bc43850f36b (patch) | |
tree | cfbef4d124f2e21b760a9dacaaa03b454d322e27 /tvix/eval/src/value/attrs.rs | |
parent | 91465dc78ec7b4a8c9b651657bb8ad5f25c556a7 (diff) |
refactor(tvix/eval): remove extra Rc<..> around Value::Attrs r/5542
The `im::OrdMap` is already small and cheap to copy while sharing memory, so this is not required anymore. Only the `KV` variant may have slightly larger content, but in practice this doesn't seem to make a difference when comparing the two variants and this one is less complicated. Change-Id: I64a563b209a2444125653777551373cb2989ca7d Reviewed-on: https://cl.tvl.fyi/c/depot/+/7677 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/value/attrs.rs')
-rw-r--r-- | tvix/eval/src/value/attrs.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs index adf56567fb0d..a41e7ce58a12 100644 --- a/tvix/eval/src/value/attrs.rs +++ b/tvix/eval/src/value/attrs.rs @@ -173,6 +173,17 @@ impl NixAttrs { Self(AttrsRep::Empty) } + /// Compare two attribute sets by pointer equality. Only makes + /// sense for some attribute set reprsentations, i.e. returning + /// `false` does not mean that the two attribute sets do not have + /// equal *content*. + pub fn ptr_eq(&self, other: &Self) -> bool { + match (&self.0, &other.0) { + (AttrsRep::Im(lhs), AttrsRep::Im(rhs)) => lhs.ptr_eq(rhs), + _ => false, + } + } + /// Return an attribute set containing the merge of the two /// provided sets. Keys from the `other` set have precedence. pub fn update(self, other: Self) -> Self { |