Avoid unnecessary referencing

Even though the compiler will do immediate derefs, let us be explicit.
next
Sayan Nandan 3 years ago
parent 03a229104d
commit b162756f80

@ -61,7 +61,7 @@ where
// if snapshots are enabled or not with `is_snapshot_enabled` // if snapshots are enabled or not with `is_snapshot_enabled`
snaphandle.snapcfg.as_ref().unsafe_unwrap() snaphandle.snapcfg.as_ref().unsafe_unwrap()
}; };
let snapengine = SnapshotEngine::new(snapstatus.max, &handle, None); let snapengine = SnapshotEngine::new(snapstatus.max, handle, None);
if snapengine.is_err() { if snapengine.is_err() {
was_engine_error = true; was_engine_error = true;
} else if snapstatus.is_busy() { } else if snapstatus.is_busy() {

@ -251,7 +251,7 @@ impl Deref for Data {
impl Borrow<[u8]> for Data { impl Borrow<[u8]> for Data {
fn borrow(&self) -> &[u8] { fn borrow(&self) -> &[u8] {
&self.blob.borrow() self.blob.borrow()
} }
} }

@ -233,7 +233,7 @@ impl Namespace {
.true_remove_if(&keyspace_idenitifer, |_ks_id, ks_atomic_ref| { .true_remove_if(&keyspace_idenitifer, |_ks_id, ks_atomic_ref| {
// 1 because this should just be us, the one instance // 1 because this should just be us, the one instance
// also the keyspace must be empty // also the keyspace must be empty
ks_atomic_ref.tables.len() == 0 && Arc::strong_count(&ks_atomic_ref) == 1 ks_atomic_ref.tables.len() == 0 && Arc::strong_count(ks_atomic_ref) == 1
}); });
if did_remove { if did_remove {
Ok(()) Ok(())
@ -318,7 +318,7 @@ impl Keyspace {
self.tables self.tables
.true_remove_if(&table_identifier, |_table_id, table_atomic_ref| { .true_remove_if(&table_identifier, |_table_id, table_atomic_ref| {
// 1 because this should just be us, the one instance // 1 because this should just be us, the one instance
Arc::strong_count(&table_atomic_ref) == 1 Arc::strong_count(table_atomic_ref) == 1
}); });
if did_remove { if did_remove {
Ok(()) Ok(())

@ -134,7 +134,7 @@ impl CoreDB {
match query { match query {
Query::SimpleQuery(q) => { Query::SimpleQuery(q) => {
con.write_simple_query_header().await?; con.write_simple_query_header().await?;
queryengine::execute_simple(&self, con, q).await?; queryengine::execute_simple(self, con, q).await?;
con.flush_stream().await?; con.flush_stream().await?;
} }
// TODO(@ohsayan): Pipeline commands haven't been implemented yet // TODO(@ohsayan): Pipeline commands haven't been implemented yet

@ -124,7 +124,7 @@ where
if self.get_buffer().is_empty() { if self.get_buffer().is_empty() {
return Err(ParseError::Empty); return Err(ParseError::Empty);
} }
protocol::Parser::new(&self.get_buffer()).parse() protocol::Parser::new(self.get_buffer()).parse()
} }
/// Read a query from the remote end /// Read a query from the remote end
/// ///

@ -136,7 +136,7 @@ impl<'a> SnapshotEngine<'a> {
"The snapshot file names have invalid characters. This should not happen! Please report an error") "The snapshot file names have invalid characters. This should not happen! Please report an error")
); );
}; };
if SNAP_MATCH.is_match(&file_name) { if SNAP_MATCH.is_match(file_name) {
// Good, the file name matched the format we were expecting // Good, the file name matched the format we were expecting
// This is a valid snapshot, add it to our `Vec` of snaps // This is a valid snapshot, add it to our `Vec` of snaps
snaps.push(path); snaps.push(path);
@ -309,7 +309,7 @@ fn test_snapshot() {
crate::coredb::Data::from(String::from("ohhey")), crate::coredb::Data::from(String::from("ohhey")),
crate::coredb::Data::from_string(String::from("heya!")), crate::coredb::Data::from_string(String::from("heya!")),
); );
let mut snapengine = SnapshotEngine::new(4, &db, Some(&ourdir)).unwrap(); let mut snapengine = SnapshotEngine::new(4, &db, Some(ourdir)).unwrap();
let _ = snapengine.mksnap_test(); let _ = snapengine.mksnap_test();
let current = snapengine.get_snapshots().next().unwrap(); let current = snapengine.get_snapshots().next().unwrap();
let read_hmap = diskstore::test_deserialize(fs::read(PathBuf::from(current)).unwrap()).unwrap(); let read_hmap = diskstore::test_deserialize(fs::read(PathBuf::from(current)).unwrap()).unwrap();

@ -356,7 +356,7 @@ fn test_ser_de_few_elements() {
assert!(de.len() == cmap.len()); assert!(de.len() == cmap.len());
assert!(de assert!(de
.iter() .iter()
.all(|kv| cmap.get(kv.key()).unwrap().eq(&kv.value()))); .all(|kv| cmap.get(kv.key()).unwrap().eq(kv.value())));
} }
cfg_test!( cfg_test!(
@ -380,7 +380,7 @@ cfg_test!(
let de = deserialize(ser).unwrap(); let de = deserialize(ser).unwrap();
assert!(de assert!(de
.iter() .iter()
.all(|kv| cmap.get(kv.key()).unwrap().eq(&kv.value()))); .all(|kv| cmap.get(kv.key()).unwrap().eq(kv.value())));
assert!(de.len() == cmap.len()); assert!(de.len() == cmap.len());
} }

Loading…
Cancel
Save