@@ -34,31 +34,6 @@ int keccak256_slice(slice s) inline {
34
34
return keccak256_tuple(slices);
35
35
}
36
36
37
- ;; Splits a slice into chunks of MAX_BITS bits or less, in reverse order
38
- (cell, slice) split_into_reverse_chunks(slice data, int size) {
39
- cell chunks = null();
40
- int total_bits_loaded = 0;
41
- builder current_chunk = begin_cell();
42
- while ((~ data.slice_empty?()) & (total_bits_loaded < size)) {
43
- int bits_to_load = min(min(data.slice_bits(), MAX_BITS - current_chunk.builder_bits()), size - total_bits_loaded);
44
- current_chunk = current_chunk.store_slice(data~load_bits(bits_to_load));
45
- total_bits_loaded += bits_to_load;
46
- if ((current_chunk.builder_bits() == MAX_BITS) | (size - total_bits_loaded == 0)) {
47
- slice current_chunk_slice = current_chunk.end_cell().begin_parse();
48
- if (cell_null?(chunks)) {
49
- chunks = begin_cell().store_slice(current_chunk_slice).end_cell();
50
- } else {
51
- chunks = begin_cell().store_slice(current_chunk_slice).store_ref(chunks).end_cell();
52
- }
53
- current_chunk = begin_cell();
54
- }
55
- if ((data.slice_bits() == 0) & (~ data.slice_refs_empty?())) {
56
- data = data~load_ref().begin_parse();
57
- }
58
- }
59
- return (chunks, data);
60
- }
61
-
62
37
{-
63
38
This function reads a specified number of bits from the input slice and stores them in a cell structure,
64
39
handling data that may exceed the maximum cell capacity in FunC (1023 bits).
99
74
}
100
75
}
101
76
77
+ ;; Push any remaining data in current_builder after the loop
78
+ if (current_builder.builder_bits() > 0) {
79
+ cell current_chunk = current_builder.end_cell();
80
+ chunk_list~tpush(current_chunk);
81
+ }
82
+
102
83
;; Build forward chain: first chunk → second chunk → third chunk etc
103
84
cell result = null();
104
85
int chunk_count = chunk_list.tlen();
0 commit comments