Skip to content

Commit

Permalink
DataOriented: Fixes the case of existing value overriding in the trie
Browse files Browse the repository at this point in the history
  • Loading branch information
aserebryakov committed Jul 5, 2018
1 parent 1542fd9 commit 89c08ad
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,18 @@ impl<T: Eq + Ord + Clone, U: Clone> Trie<T, U> {
}
}

// TODO: Check if node already contains value
self.values.push(value);
self.nodes[node_id].set_value(self.values.len() - 1);
let value_id = match self.nodes[node_id].get_value() {
Some(id) => {
self.values[id] = value;
id
}
None => {
self.values.push(value);
self.values.len() - 1
}
};

self.nodes[node_id].set_value(value_id);
}

/// Clears the trie
Expand Down

0 comments on commit 89c08ad

Please sign in to comment.