Merge with master
This commit is contained in:
@@ -132,15 +132,10 @@ macro_rules! impl_hash {
|
||||
$size
|
||||
}
|
||||
|
||||
// TODO: remove once slice::clone_from_slice is stable
|
||||
#[inline]
|
||||
fn clone_from_slice(&mut self, src: &[u8]) -> usize {
|
||||
let min = ::std::cmp::min($size, src.len());
|
||||
let dst = &mut self.deref_mut()[.. min];
|
||||
let src = &src[.. min];
|
||||
for i in 0..min {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
let min = cmp::min($size, src.len());
|
||||
self.0[..min].copy_from_slice(&src[..min]);
|
||||
min
|
||||
}
|
||||
|
||||
@@ -151,7 +146,7 @@ macro_rules! impl_hash {
|
||||
}
|
||||
|
||||
fn copy_to(&self, dest: &mut[u8]) {
|
||||
let min = ::std::cmp::min($size, dest.len());
|
||||
let min = cmp::min($size, dest.len());
|
||||
dest[..min].copy_from_slice(&self.0[..min]);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,16 @@ impl Database {
|
||||
opts.set_block_based_table_factory(&block_opts);
|
||||
opts.set_prefix_extractor_fixed_size(size);
|
||||
}
|
||||
let db = try!(DB::open(&opts, path));
|
||||
let db = match DB::open(&opts, path) {
|
||||
Ok(db) => db,
|
||||
Err(ref s) if s.starts_with("Corruption:") => {
|
||||
info!("{}", s);
|
||||
info!("Attempting DB repair for {}", path);
|
||||
try!(DB::repair(&opts, path));
|
||||
try!(DB::open(&opts, path))
|
||||
},
|
||||
Err(s) => { return Err(s); }
|
||||
};
|
||||
Ok(Database { db: db })
|
||||
}
|
||||
|
||||
|
||||
@@ -258,14 +258,7 @@ impl <T>FromBytes for T where T: FixedHash {
|
||||
Ordering::Equal => ()
|
||||
};
|
||||
|
||||
unsafe {
|
||||
use std::{mem, ptr};
|
||||
|
||||
let mut res: T = mem::uninitialized();
|
||||
ptr::copy(bytes.as_ptr(), res.as_slice_mut().as_mut_ptr(), T::len());
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
Ok(T::from_slice(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user