@@ -103,6 +103,12 @@ impl From<Value> for RcValue {
103103 }
104104}
105105
106+ impl From < Arc < Value > > for RcValue {
107+ fn from ( value : Arc < Value > ) -> Self {
108+ Self ( value)
109+ }
110+ }
111+
106112#[ cfg( test) ]
107113impl < const N : usize > TryFrom < RcValue > for [ u8 ; N ] {
108114 type Error = <[ u8 ; N ] as TryFrom < Vec < u8 > > >:: Error ;
@@ -495,9 +501,10 @@ impl DbInner {
495501 } ) )
496502 }
497503
498- fn commit_changes < I > ( & self , tx : I ) -> Result < ( ) >
504+ fn commit_changes < I , V > ( & self , tx : I ) -> Result < ( ) >
499505 where
500- I : IntoIterator < Item = ( ColId , Operation < Vec < u8 > , Vec < u8 > > ) > ,
506+ I : IntoIterator < Item = ( ColId , Operation < Vec < u8 > , V > ) > ,
507+ V : Into < RcValue > ,
501508 {
502509 let mut commit: CommitChangeSet = Default :: default ( ) ;
503510 for ( col, change) in tx. into_iter ( ) {
@@ -564,7 +571,8 @@ impl DbInner {
564571 } ,
565572 Operation :: ReferenceTree ( ..) => {
566573 if !self . options . columns [ col as usize ] . append_only {
567- let root_operation = Operation :: Reference ( change. key ( ) ) ;
574+ let root_operation =
575+ Operation :: < & _ , V > :: Reference ( change. key ( ) ) ;
568576 commit
569577 . indexed
570578 . entry ( col)
@@ -1562,6 +1570,16 @@ impl Db {
15621570 self . inner . commit_changes ( tx)
15631571 }
15641572
1573+ /// Commit a set of changes to the database.
1574+ ///
1575+ /// This method passes values as `Arc<Vec<u8>>` potentially eliminating an extra copy.
1576+ pub fn commit_changes_shared < I > ( & self , tx : I ) -> Result < ( ) >
1577+ where
1578+ I : IntoIterator < Item = ( ColId , Operation < Vec < u8 > , Arc < Vec < u8 > > > ) > ,
1579+ {
1580+ self . inner . commit_changes ( tx)
1581+ }
1582+
15651583 pub ( crate ) fn commit_raw ( & self , commit : CommitChangeSet ) -> Result < ( ) > {
15661584 self . inner . commit_raw ( commit)
15671585 }
@@ -2091,9 +2109,9 @@ impl IndexedChangeSet {
20912109 }
20922110 }
20932111
2094- fn push < K : AsRef < [ u8 ] > > (
2112+ fn push < K : AsRef < [ u8 ] > , V : Into < RcValue > > (
20952113 & mut self ,
2096- change : Operation < K , Vec < u8 > > ,
2114+ change : Operation < K , V > ,
20972115 options : & Options ,
20982116 db_version : u32 ,
20992117 ) -> Result < ( ) > {
0 commit comments