Skip to content

Commit

Permalink
Pre-allocate vector size (#1960)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonedaddy authored Oct 3, 2023
1 parent 560252f commit be516f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,12 @@ impl Index {

pub(crate) fn rare_sat_satpoints(&self) -> Result<Option<Vec<(Sat, SatPoint)>>> {
if self.has_sat_index()? {
let mut result = Vec::new();

let rtx = self.database.begin_read()?;

let sat_to_satpoint = rtx.open_table(SAT_TO_SATPOINT)?;

let mut result = Vec::with_capacity(sat_to_satpoint.len()?.try_into().unwrap());

for range in sat_to_satpoint.range(0..)? {
let (sat, satpoint) = range?;
result.push((Sat(sat.value()), Entry::load(*satpoint.value())));
Expand Down

0 comments on commit be516f8

Please sign in to comment.