d4566ff6ea
Instead of creating a new Vec<_> for every embedded path part, we now use a reference when calling get/set/del on a value’s data. This means we aren’t creating and copying the Vec items each and every time we traverse down a path.
26 lines
530 B
Rust
26 lines
530 B
Rust
use crate::dbs::Options;
|
|
use crate::dbs::Runtime;
|
|
use crate::dbs::Transaction;
|
|
use crate::err::Error;
|
|
use crate::sql::part::Part;
|
|
use crate::sql::value::Value;
|
|
|
|
impl Value {
|
|
pub async fn merge(
|
|
&mut self,
|
|
ctx: &Runtime,
|
|
opt: &Options,
|
|
txn: &Transaction,
|
|
val: &Value,
|
|
) -> Result<(), Error> {
|
|
match val.compute(ctx, opt, txn, Some(self)).await? {
|
|
Value::Object(v) => {
|
|
for (k, v) in v.value.into_iter() {
|
|
self.set(ctx, opt, txn, &[Part::from(k)], v).await?;
|
|
}
|
|
Ok(())
|
|
}
|
|
_ => Ok(()),
|
|
}
|
|
}
|
|
}
|