omnizip 0.3.16 → 0.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/omnizip/algorithms/zstandard/match_finder.rb +56 -1
- data/lib/omnizip/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26bb587688afe9104a60ed3db30bd0b4d4a0ad909d1f02d0afaf3c8b67343119
|
|
4
|
+
data.tar.gz: 674f6bdf6fa36ec488ad06aa3f0a98ba792945fff3d244e9913ee06ff64402a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed59928f26cec56627b12304d9cf55d3ed04a7ee07f0a3bf2ef6f71b44a0e21d76d4246746db8f5dd0751139f68208a5a5a53c81ce9959f4433f883d3648adfc
|
|
7
|
+
data.tar.gz: 311d21ef3715257f1db58f9c1238200d04dce604022337fa53adf7a2c95d1a2d1272ba75bbcae55aaaf5d5b97a16ef954e7ab1b423e9f6875abb1f1036653a6b
|
|
@@ -177,7 +177,12 @@ module Omnizip
|
|
|
177
177
|
limit = block_end - mm
|
|
178
178
|
|
|
179
179
|
while ip < limit
|
|
180
|
-
match =
|
|
180
|
+
match = if lazy.zero?
|
|
181
|
+
find_greedy_match(src, ip, ms, mm, limit, anchor,
|
|
182
|
+
seq_store.rep_offsets[0])
|
|
183
|
+
else
|
|
184
|
+
find_best_match(src, ip, ms, mm, limit)
|
|
185
|
+
end
|
|
181
186
|
if match
|
|
182
187
|
dist, len = match
|
|
183
188
|
defer = false
|
|
@@ -198,6 +203,7 @@ module Omnizip
|
|
|
198
203
|
next
|
|
199
204
|
end
|
|
200
205
|
|
|
206
|
+
ip = match[2] if match.length == 3
|
|
201
207
|
seq_store.literals << src.byteslice(anchor, ip - anchor)
|
|
202
208
|
seq_store.sequences <<
|
|
203
209
|
RawSequence.new(ip - anchor, len, dist)
|
|
@@ -218,6 +224,55 @@ module Omnizip
|
|
|
218
224
|
# rubocop:enable Metrics/AbcSize
|
|
219
225
|
# rubocop:enable Metrics/MethodLength
|
|
220
226
|
|
|
227
|
+
# Greedy-path match search (port of the Rust
|
|
228
|
+
# compress_block_with_min_match): the rep0 fast-path first
|
|
229
|
+
# (cheapest offset to encode), then the hash table — both
|
|
230
|
+
# with backward extension into the pending literals. Returns
|
|
231
|
+
# [offset, length, start] or nil.
|
|
232
|
+
def find_greedy_match(src, ip, ms, min_match, limit, anchor, rep0)
|
|
233
|
+
m = rep0_match(src, ip, rep0, min_match, limit, anchor)
|
|
234
|
+
return m if m
|
|
235
|
+
|
|
236
|
+
dist, len = find_best_match(src, ip, ms, min_match, limit)
|
|
237
|
+
return nil unless dist
|
|
238
|
+
|
|
239
|
+
back = backward_extension(src, ip, anchor, ip - dist)
|
|
240
|
+
[dist, len + back, ip - back]
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Match at distance rep0 (the decoder's most recent offset)
|
|
244
|
+
# with forward and backward extension. [rep0, length, start]
|
|
245
|
+
# or nil.
|
|
246
|
+
#
|
|
247
|
+
# rubocop:disable-next Metrics/AbcSize
|
|
248
|
+
def rep0_match(src, ip, rep0, min_match, limit, anchor)
|
|
249
|
+
return nil if rep0 <= 0 || ip <= rep0
|
|
250
|
+
return nil if src.byteslice(ip, MIN_MATCH) !=
|
|
251
|
+
src.byteslice(ip - rep0, MIN_MATCH)
|
|
252
|
+
|
|
253
|
+
m_len = MIN_MATCH + count_match(
|
|
254
|
+
src, ip + MIN_MATCH, src, ip + MIN_MATCH - rep0,
|
|
255
|
+
[limit + MIN_MATCH_ECONOMICAL - ip - MIN_MATCH, 0].max
|
|
256
|
+
)
|
|
257
|
+
back = backward_extension(src, ip, anchor, ip - rep0)
|
|
258
|
+
m_len += back
|
|
259
|
+
return nil if m_len < min_match
|
|
260
|
+
|
|
261
|
+
[rep0, m_len, ip - back]
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# Bytes before `ip` (and before the match candidate) that
|
|
265
|
+
# extend the match backward, bounded by the pending literal
|
|
266
|
+
# run so the previous sequence is never overlapped.
|
|
267
|
+
def backward_extension(src, ip, anchor, candidate)
|
|
268
|
+
back = 0
|
|
269
|
+
while ip > anchor + back && candidate > back &&
|
|
270
|
+
src.getbyte(ip - 1 - back) == src.getbyte(candidate - 1 - back)
|
|
271
|
+
back += 1
|
|
272
|
+
end
|
|
273
|
+
back
|
|
274
|
+
end
|
|
275
|
+
|
|
221
276
|
# Find the best match at `ip` (single probe, or a chain walk
|
|
222
277
|
# when enabled). Updates the hash table. Returns
|
|
223
278
|
# [distance, length] or nil.
|
data/lib/omnizip/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omnizip
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|