Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/compress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ pub struct Compressor {
dp_costs: Vec<u32>,
dp_path: Vec<u32>,
split_stats: BlockSplitStats,
matches: Vec<(u16, u16)>,
}

impl Compressor {
Expand Down Expand Up @@ -498,6 +499,11 @@ impl Compressor {
Vec::new()
},
split_stats: BlockSplitStats::new(),
matches: if level >= 10 {
Vec::with_capacity(32)
} else {
Vec::new()
},
};
c.init_params();
c
Expand Down Expand Up @@ -960,7 +966,6 @@ impl Compressor {
}

mf.reset();
let mut matches = Vec::new();
let mut pos = 0;
while pos < processed {
let cur_cost = self.dp_costs[pos];
Expand All @@ -980,10 +985,10 @@ impl Compressor {
pos,
self.max_search_depth,
self.nice_match_length,
&mut matches,
&mut self.matches,
);
let mut best_len = 0;
for &(len, offset) in &matches {
for &(len, offset) in &self.matches {
let len = len as usize;
if pos + len > processed {
continue;
Expand Down Expand Up @@ -1757,7 +1762,6 @@ impl Compressor {
}

mf.reset();
let mut matches = Vec::new();
let mut pos = 0;
while pos < processed {
let cur_cost = self.dp_costs[pos];
Expand All @@ -1777,10 +1781,10 @@ impl Compressor {
pos,
self.max_search_depth,
self.nice_match_length,
&mut matches,
&mut self.matches,
);
let mut best_len = 0;
for &(len, offset) in &matches {
for &(len, offset) in &self.matches {
let len = len as usize;
if pos + len > processed {
continue;
Expand Down