diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index 261408766..e8987837c 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -13,7 +13,7 @@ // limitations under the License. use std::cmp::max; -use std::io::{Cursor, Write}; +use std::io::Write; use itertools::Itertools; @@ -264,7 +264,7 @@ pub fn conflict_to_materialized_value( ) -> TreeValue { let mut buf = vec![]; materialize_conflict(store, path, conflict, &mut buf).unwrap(); - let file_id = store.write_file(path, &mut Cursor::new(&buf)).unwrap(); + let file_id = store.write_file(path, &mut buf.as_slice()).unwrap(); TreeValue::File { id: file_id, executable: false, @@ -426,7 +426,7 @@ pub fn update_conflict_from_content( // with conflict markers. Update the Conflict object with the new // FileIds. for (i, buf) in removed_content.iter().enumerate() { - let file_id = store.write_file(path, &mut Cursor::new(buf))?; + let file_id = store.write_file(path, &mut buf.as_slice())?; if let TreeValue::File { id, executable: _ } = &mut conflict.removes[i].value { *id = file_id; } else { @@ -437,7 +437,7 @@ pub fn update_conflict_from_content( } } for (i, buf) in added_content.iter().enumerate() { - let file_id = store.write_file(path, &mut Cursor::new(buf))?; + let file_id = store.write_file(path, &mut buf.as_slice())?; if let TreeValue::File { id, executable: _ } = &mut conflict.adds[i].value { *id = file_id; } else { diff --git a/lib/src/default_index_store.rs b/lib/src/default_index_store.rs index 3c105ae55..5ebfd72b9 100644 --- a/lib/src/default_index_store.rs +++ b/lib/src/default_index_store.rs @@ -18,7 +18,7 @@ use std::collections::{BTreeMap, BTreeSet, BinaryHeap, Bound, HashMap, HashSet}; use std::fmt::{Debug, Formatter}; use std::fs::File; use std::hash::{Hash, Hasher}; -use std::io::{Cursor, Read, Write}; +use std::io::{Read, Write}; use std::ops::Range; use std::path::{Path, PathBuf}; use std::sync::Arc; @@ -670,9 +670,8 @@ impl MutableIndexImpl { file.write_all(&buf)?; persist_content_addressed_temp_file(temp_file, index_file_path)?; - let mut cursor = Cursor::new(&buf); ReadonlyIndexImpl::load_from( - &mut cursor, + &mut buf.as_slice(), dir, index_file_id_hex, commit_id_length, diff --git a/lib/src/stacked_table.rs b/lib/src/stacked_table.rs index c22bbd52e..e9b61000c 100644 --- a/lib/src/stacked_table.rs +++ b/lib/src/stacked_table.rs @@ -22,7 +22,7 @@ use std::cmp::Ordering; use std::collections::{BTreeMap, HashMap}; use std::fs::File; use std::io; -use std::io::{Cursor, Read, Write}; +use std::io::{Read, Write}; use std::path::PathBuf; use std::sync::{Arc, RwLock}; @@ -337,8 +337,7 @@ impl MutableTable { file.write_all(&buf)?; persist_content_addressed_temp_file(temp_file, file_path)?; - let mut cursor = Cursor::new(&buf); - ReadonlyTable::load_from(&mut cursor, store, file_id_hex, store.key_size) + ReadonlyTable::load_from(&mut buf.as_slice(), store, file_id_hex, store.key_size) } }