Skip to content

Commit 08c9127

Browse files
committed
Fixed wrong reserve (+1% speed!)
1 parent c8b70d8 commit 08c9127

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

webgraph/src/graphs/bvgraph/sequential.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ impl<D: Decode> NodeLabels<D> {
241241
/// Get the successors of the next node in the stream
242242
pub fn next_successors(&mut self) -> Result<&[usize]> {
243243
let mut res = self.backrefs.take(self.current_node);
244-
res.clear();
245244
self.get_successors_iter_priv(self.current_node, &mut res)?;
246245
let res = self.backrefs.replace(self.current_node, res);
247246
self.current_node += 1;
@@ -256,8 +255,9 @@ impl<D: Decode> NodeLabels<D> {
256255
return Ok(());
257256
}
258257

258+
results.clear();
259259
// ensure that we have enough capacity in the vector for not reallocating
260-
results.reserve(degree.saturating_sub(results.capacity()));
260+
results.reserve(degree);
261261
// read the reference offset
262262
let ref_delta = if self.compression_window != 0 {
263263
self.decoder.read_reference_offset() as usize

0 commit comments

Comments
 (0)