My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove unused lookup tables and simplify code

- Remove unused _char_table (was reserved for future lookup optimization)
- Remove unused _max_block_size constant
- Remove unused _copy_8_bytes helper function
- Simplify is_valid_compressed using Option.is_some
- Simplify decompress_stream_is_complete using direct comparison

No functional changes - all 62 tests still pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+3 -65
+3 -65
src/snappy.ml
··· 8 8 let tag_copy4 = 3 (* 4-byte offset *) 9 9 10 10 (* Constants *) 11 - let _max_block_size = 1 lsl 16 (* 64KB blocks for compression, reserved for future *) 12 11 let max_hash_table_bits = 14 13 12 let max_hash_table_size = 1 lsl max_hash_table_bits 14 13 let max_offset = 1 lsl 15 (* 32KB window *) 15 - 16 - (* ============================================================ 17 - Lookup table for fast tag decoding (from snappy-c) 18 - Format: bits 0-7 = length, bits 8-10 = offset>>8, bits 11-13 = extra bytes 19 - For tag type 0 (literal), length-1 is stored if < 60 20 - For tag type 1 (copy1), length-4 and offset high bits encoded 21 - For tag type 2 (copy2), length-1 stored 22 - For tag type 3 (copy4), length-1 stored 23 - 0xFFFF means "use slow path" (long literal or copy4) 24 - ============================================================ *) 25 - let _char_table = [| 26 - 0x0001; 0x0804; 0x1001; 0x2001; 0x0002; 0x0805; 0x1002; 0x2002; 27 - 0x0003; 0x0806; 0x1003; 0x2003; 0x0004; 0x0807; 0x1004; 0x2004; 28 - 0x0005; 0x0808; 0x1005; 0x2005; 0x0006; 0x0809; 0x1006; 0x2006; 29 - 0x0007; 0x080a; 0x1007; 0x2007; 0x0008; 0x080b; 0x1008; 0x2008; 30 - 0x0009; 0x0904; 0x1009; 0x2009; 0x000a; 0x0905; 0x100a; 0x200a; 31 - 0x000b; 0x0906; 0x100b; 0x200b; 0x000c; 0x0907; 0x100c; 0x200c; 32 - 0x000d; 0x0908; 0x100d; 0x200d; 0x000e; 0x0909; 0x100e; 0x200e; 33 - 0x000f; 0x090a; 0x100f; 0x200f; 0x0010; 0x090b; 0x1010; 0x2010; 34 - 0x0011; 0x0a04; 0x1011; 0x2011; 0x0012; 0x0a05; 0x1012; 0x2012; 35 - 0x0013; 0x0a06; 0x1013; 0x2013; 0x0014; 0x0a07; 0x1014; 0x2014; 36 - 0x0015; 0x0a08; 0x1015; 0x2015; 0x0016; 0x0a09; 0x1016; 0x2016; 37 - 0x0017; 0x0a0a; 0x1017; 0x2017; 0x0018; 0x0a0b; 0x1018; 0x2018; 38 - 0x0019; 0x0b04; 0x1019; 0x2019; 0x001a; 0x0b05; 0x101a; 0x201a; 39 - 0x001b; 0x0b06; 0x101b; 0x201b; 0x001c; 0x0b07; 0x101c; 0x201c; 40 - 0x001d; 0x0b08; 0x101d; 0x201d; 0x001e; 0x0b09; 0x101e; 0x201e; 41 - 0x001f; 0x0b0a; 0x101f; 0x201f; 0x0020; 0x0b0b; 0x1020; 0x2020; 42 - 0x0021; 0x0c04; 0x1021; 0x2021; 0x0022; 0x0c05; 0x1022; 0x2022; 43 - 0x0023; 0x0c06; 0x1023; 0x2023; 0x0024; 0x0c07; 0x1024; 0x2024; 44 - 0x0025; 0x0c08; 0x1025; 0x2025; 0x0026; 0x0c09; 0x1026; 0x2026; 45 - 0x0027; 0x0c0a; 0x1027; 0x2027; 0x0028; 0x0c0b; 0x1028; 0x2028; 46 - 0x0029; 0x0d04; 0x1029; 0x2029; 0x002a; 0x0d05; 0x102a; 0x202a; 47 - 0x002b; 0x0d06; 0x102b; 0x202b; 0x002c; 0x0d07; 0x102c; 0x202c; 48 - 0x002d; 0x0d08; 0x102d; 0x202d; 0x002e; 0x0d09; 0x102e; 0x202e; 49 - 0x002f; 0x0d0a; 0x102f; 0x202f; 0x0030; 0x0d0b; 0x1030; 0x2030; 50 - 0x0031; 0x0e04; 0x1031; 0x2031; 0x0032; 0x0e05; 0x1032; 0x2032; 51 - 0x0033; 0x0e06; 0x1033; 0x2033; 0x0034; 0x0e07; 0x1034; 0x2034; 52 - 0x0035; 0x0e08; 0x1035; 0x2035; 0x0036; 0x0e09; 0x1036; 0x2036; 53 - 0x0037; 0x0e0a; 0x1037; 0x2037; 0x0038; 0x0e0b; 0x1038; 0x2038; 54 - 0x0039; 0x0f04; 0x1039; 0x2039; 0x003a; 0x0f05; 0x103a; 0x203a; 55 - 0x003b; 0x0f06; 0x103b; 0x203b; 0x003c; 0x0f07; 0x103c; 0x203c; 56 - 0x0801; 0x0f08; 0x103d; 0x203d; 0x1001; 0x0f09; 0x103e; 0x203e; 57 - 0x1801; 0x0f0a; 0x103f; 0x203f; 0x2001; 0x0f0b; 0x1040; 0x2040; 58 - |] 59 14 60 15 (* Error type *) 61 16 type error = ··· 125 80 if logand !x 0x3L = 0L then begin n := !n + 2; x := shift_right_logical !x 2 end; 126 81 if logand !x 0x1L = 0L then n := !n + 1; 127 82 !n 128 - 129 - (* Fast 8-byte copy using individual byte copies (avoids Bytes.blit overhead for small copies) *) 130 - let[@inline always] _copy_8_bytes dst dst_pos src src_pos = 131 - set_u8 dst dst_pos (get_u8 src src_pos); 132 - set_u8 dst (dst_pos+1) (get_u8 src (src_pos+1)); 133 - set_u8 dst (dst_pos+2) (get_u8 src (src_pos+2)); 134 - set_u8 dst (dst_pos+3) (get_u8 src (src_pos+3)); 135 - set_u8 dst (dst_pos+4) (get_u8 src (src_pos+4)); 136 - set_u8 dst (dst_pos+5) (get_u8 src (src_pos+5)); 137 - set_u8 dst (dst_pos+6) (get_u8 src (src_pos+6)); 138 - set_u8 dst (dst_pos+7) (get_u8 src (src_pos+7)) 139 83 140 84 (* ============================================================ 141 85 Varint encoding/decoding ··· 738 682 739 683 (* Check if data looks like valid snappy compressed data *) 740 684 let is_valid_compressed s = 741 - if String.length s < 1 then false 742 - else 743 - let src = Bytes.unsafe_of_string s in 744 - match get_uncompressed_length src ~pos:0 ~len:(String.length s) with 745 - | None -> false 746 - | Some len -> len >= 0 && len <= 0xFFFFFFFF 685 + String.length s >= 1 && 686 + Option.is_some (get_uncompressed_length (Bytes.unsafe_of_string s) ~pos:0 ~len:(String.length s)) 747 687 748 688 (* ============================================================ 749 689 Reusable Compression Context ··· 1195 1135 1196 1136 (* Check if decompression stream is in a valid final state *) 1197 1137 let decompress_stream_is_complete ds = 1198 - match ds.ds_state with 1199 - | DS_ChunkHeader -> true 1200 - | _ -> false 1138 + ds.ds_state = DS_ChunkHeader 1201 1139 1202 1140 (* ============================================================ 1203 1141 Framing Format: Complete String API