Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Don't compare rc against i32::MIN
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdplm committed May 31, 2018
1 parent ada0b7e commit 56af2c4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions util/memorydb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<H: Hasher> MemoryDB<H> {
}

impl<H: Hasher> HashDB for MemoryDB<H> {
type H = H; // REVIEW this is a bit confusing, but not sure what is better (e.g. using `impl<HH: Hasher> … … type H = HH;`)
type H = H;

// REVIEW: this method is what made it necessary to add a type param to H256FastMap, which I'd rather have avoided.
// The problem is that the keys returned are `H256` and type inference fails on the `collect()` call.
Expand Down Expand Up @@ -222,7 +222,7 @@ impl<H: Hasher> HashDB for MemoryDB<H> {
match self.data.entry(key) {
Entry::Occupied(mut entry) => {
let &mut (ref mut old_value, ref mut rc) = entry.get_mut();
if *rc >= -0x80000000i32 && *rc <= 0 {
if *rc <= 0 {
*old_value = DBValue::from_slice(value);
}
*rc += 1;
Expand All @@ -242,7 +242,7 @@ impl<H: Hasher> HashDB for MemoryDB<H> {
match self.data.entry(key) {
Entry::Occupied(mut entry) => {
let &mut (ref mut old_value, ref mut rc) = entry.get_mut();
if *rc >= -0x80000000i32 && *rc <= 0 {
if *rc <= 0 {
*old_value = value;
}
*rc += 1;
Expand Down

0 comments on commit 56af2c4

Please sign in to comment.