-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Trie optimizations #6389
Trie optimizations #6389
Conversation
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rc >= -0x80000000i32
is probably not needed, right @rphmeier ?
@@ -181,7 +181,10 @@ impl HashDB for MemoryDB { | |||
} | |||
|
|||
fn keys(&self) -> HashMap<H256, i32> { | |||
self.data.iter().filter_map(|(k, v)| if v.1 != 0 {Some((k.clone(), v.1))} else {None}).collect() | |||
self.data.iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove a filter_map
? Clippy produces a warning on .filter().map()
sequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, ok
I just found it more readable than this long one-liner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
util/src/trie/triedb.rs
Outdated
node: node.clone().into(), | ||
}); | ||
} | ||
fn seek_descend<'key>(&mut self, mut node_data: DBValue, mut key: NibbleSlice<'key>) -> super::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be renamed to just seek
since it is not recursive anymore.
util/src/trie/triedb.rs
Outdated
fn seek_descend<'key>(&mut self, mut node_data: DBValue, mut key: NibbleSlice<'key>) -> super::Result<()> { | ||
enum Step { | ||
Descend(DBValue, usize), | ||
Return, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be just a return
statement
@arkpar fixed |
js failure is unrelated |
changes:
insert
,remove
andemplace
keys()
all trie insert benchmarks are about 10% faster