feat(tvix/eval): NixList::concat(): avoid an unnecessary move
In `a++b`, the previous implementation would move `b` (i.e. memcpy its elements) twice. Let's do that only once. We sure do call NixList.clone() a whole lot. At some point in the future we probably want to do a SmolStr-type split for NixList into a two-variant enum where one side is an Rc<Vec<Value>> for lists longer than a certain length. Signed-off-by: Adam Joseph <adam@westernsemico.com> Change-Id: I32154d18785a1f663454a8b9d4afd3e78bffdf9c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7040 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
4b01e594d5
commit
c91d86ee5c
1 changed files with 3 additions and 4 deletions
|
@ -50,10 +50,9 @@ mod arbitrary {
|
|||
|
||||
impl NixList {
|
||||
pub fn concat(&self, other: &Self) -> Self {
|
||||
let mut lhs = self.clone();
|
||||
let mut rhs = other.clone();
|
||||
lhs.0.append(&mut rhs.0);
|
||||
lhs
|
||||
let mut ret = self.clone();
|
||||
ret.0.extend_from_slice(&other.0);
|
||||
ret
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
|
|
Loading…
Reference in a new issue