From e8ca8d61edfcf5807ef47fe6f1d724cd47d2d7bb Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Fri, 14 Jul 2023 11:09:07 +0800 Subject: [PATCH] feat(minor): add a min match size --- crates/compact-bytes/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/compact-bytes/src/lib.rs b/crates/compact-bytes/src/lib.rs index 57e6215c..25424514 100644 --- a/crates/compact-bytes/src/lib.rs +++ b/crates/compact-bytes/src/lib.rs @@ -97,9 +97,10 @@ impl CompactBytes { } let mut index = 0; + let min_match_size = 4.min(bytes.len()); while index < bytes.len() { match self.lookup(&bytes[index..]) { - Some((pos, len)) if len >= 4 => { + Some((pos, len)) if len >= min_match_size => { push_with_merge(&mut ans, pos..pos + len); index += len; }