mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 00:38:14 +01:00
Rename [i:j] to [i .. j], the same as Rust
This commit is contained in:
1 parent
7872a8893b
commit
a9ea63ff06
16 files changed
+55
-50
No files matched your search
@@ -36,10 +36,10 @@ pub func hasher.update!(x slice base.u8) base.u32 {
|
||||
s2 = this.state.high_bits(n:16)
|
||||
|
||||
while args.x.length() > 0 {
|
||||
remaining = args.x[:0]
|
||||
remaining = args.x[.. 0]
|
||||
if args.x.length() > 5552 {
|
||||
remaining = args.x[5552:]
|
||||
args.x = args.x[:5552]
|
||||
remaining = args.x[5552 ..]
|
||||
args.x = args.x[.. 5552]
|
||||
}
|
||||
|
||||
iterate (p = args.x)(length:1, unroll:8) {
|
||||
|
||||
@@ -144,12 +144,12 @@ pub func decoder.add_history!(hist slice base.u8) {
|
||||
// If s is longer than the ringbuffer, we can ignore the previous value
|
||||
// of history_index, as we will overwrite the whole ringbuffer.
|
||||
s = s.suffix(up_to:0x8000)
|
||||
this.history[:].copy_from_slice!(s:s)
|
||||
this.history[..].copy_from_slice!(s:s)
|
||||
this.history_index = 0x8000
|
||||
} else {
|
||||
// Otherwise, append s to the history ringbuffer starting at the
|
||||
// previous history_index (modulo 0x8000).
|
||||
n_copied = this.history[this.history_index & 0x7FFF:].copy_from_slice!(s:s)
|
||||
n_copied = this.history[this.history_index & 0x7FFF ..].copy_from_slice!(s:s)
|
||||
if n_copied < s.length() {
|
||||
// a_slice.copy_from(s:b_slice) returns the minimum of the two
|
||||
// slice lengths. If that value is less than b_slice.length(), then
|
||||
@@ -158,8 +158,8 @@ pub func decoder.add_history!(hist slice base.u8) {
|
||||
// In terms of the history ringbuffer, that means that we have to
|
||||
// wrap around and copy the remainder of s over the start of the
|
||||
// history ringbuffer.
|
||||
s = s[n_copied:]
|
||||
n_copied = this.history[:].copy_from_slice!(s:s)
|
||||
s = s[n_copied ..]
|
||||
n_copied = this.history[..].copy_from_slice!(s:s)
|
||||
// Set history_index (modulo 0x8000) to the length of this
|
||||
// remainder. The &0x7FFF is redundant, but proves to the compiler
|
||||
// that the conversion to u32 will not overflow. The +0x8000 is to
|
||||
|
||||
@@ -331,12 +331,12 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
||||
// "args.dst.available() >= 258" fact. It should certainly
|
||||
// invalidate any fact that was "<=" instead of ">=".
|
||||
n_copied = args.dst.copy_n_from_slice!(
|
||||
n:hlen, s:this.history[hdist & 0x7FFF:])
|
||||
n:hlen, s:this.history[hdist & 0x7FFF ..])
|
||||
if hlen <= n_copied {
|
||||
break
|
||||
}
|
||||
hlen -= n_copied
|
||||
args.dst.copy_n_from_slice!(n:hlen, s:this.history[:])
|
||||
args.dst.copy_n_from_slice!(n:hlen, s:this.history[..])
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
||||
// Copy from hdist to the end of this.history.
|
||||
while true {
|
||||
n_copied = args.dst.copy_n_from_slice!(
|
||||
n:hlen, s:this.history[hdist & 0x7FFF:])
|
||||
n:hlen, s:this.history[hdist & 0x7FFF ..])
|
||||
if hlen <= n_copied {
|
||||
hlen = 0
|
||||
break
|
||||
@@ -246,7 +246,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
||||
if hlen > 0 {
|
||||
while true {
|
||||
n_copied = args.dst.copy_n_from_slice!(
|
||||
n:hlen, s:this.history[hdist & 0x7FFF:])
|
||||
n:hlen, s:this.history[hdist & 0x7FFF ..])
|
||||
if hlen <= n_copied {
|
||||
hlen = 0
|
||||
break
|
||||
|
||||
+11
-11
@@ -932,7 +932,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
|
||||
} else if this.quirk_enabled_reject_empty_palette and (not this.has_global_palette) {
|
||||
return "#bad palette"
|
||||
} else if this.gc_has_transparent_index {
|
||||
this.palettes[1][:].copy_from_slice!(s:this.palettes[0][:])
|
||||
this.palettes[1][..].copy_from_slice!(s:this.palettes[0][..])
|
||||
} else {
|
||||
which_palette = 0
|
||||
}
|
||||
@@ -947,7 +947,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
|
||||
|
||||
dst_palette = args.dst.palette()
|
||||
if dst_palette.length() == 0 {
|
||||
dst_palette = this.dst_palette[:]
|
||||
dst_palette = this.dst_palette[..]
|
||||
}
|
||||
|
||||
// TODO: a Wuffs (not just C) name for the
|
||||
@@ -956,7 +956,7 @@ pri func decoder.decode_id_part1?(dst ptr base.pixel_buffer, src base.io_reader)
|
||||
dst_pixfmt:args.dst.pixel_format(),
|
||||
dst_palette:dst_palette,
|
||||
src_pixfmt:0x47040008,
|
||||
src_palette:this.palettes[which_palette][:])
|
||||
src_palette:this.palettes[which_palette][..])
|
||||
if not status.is_ok() {
|
||||
return status
|
||||
}
|
||||
@@ -1026,7 +1026,7 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
|
||||
break
|
||||
}
|
||||
compressed = args.src.take!(n:n_compressed)
|
||||
this.compressed[this.compressed_wi:].copy_from_slice!(s:compressed)
|
||||
this.compressed[this.compressed_wi ..].copy_from_slice!(s:compressed)
|
||||
this.compressed_wi ~sat+= n_compressed
|
||||
block_size ~sat-= n_compressed
|
||||
if block_size > 0 {
|
||||
@@ -1048,7 +1048,7 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
|
||||
if (this.compressed_ri > this.compressed_wi) or (this.compressed_wi > 4096) {
|
||||
return "#internal error: inconsistent ri/wi"
|
||||
}
|
||||
io_bind (io:r, data:this.compressed[this.compressed_ri:this.compressed_wi]) {
|
||||
io_bind (io:r, data:this.compressed[this.compressed_ri .. this.compressed_wi]) {
|
||||
mark = r.mark()
|
||||
lzw_status =? this.lzw.decode_io_writer?(
|
||||
dst:this.util.empty_io_writer(), src:r, workbuf:this.util.empty_slice_u8())
|
||||
@@ -1125,7 +1125,7 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
||||
width_in_bytes = (this.width as base.u64) * (bytes_per_pixel as base.u64)
|
||||
tab = args.pb.plane(p:0)
|
||||
while src_ri < args.src.length() {
|
||||
src = args.src[src_ri:]
|
||||
src = args.src[src_ri ..]
|
||||
|
||||
if this.dst_y >= this.frame_rect_y1 {
|
||||
if this.quirk_enabled_ignore_too_much_pixel_data {
|
||||
@@ -1139,21 +1139,21 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
||||
|
||||
dst = tab.row(y:this.dst_y)
|
||||
if this.dst_y >= this.height {
|
||||
dst = dst[:0]
|
||||
dst = dst[.. 0]
|
||||
} else if width_in_bytes < dst.length() {
|
||||
dst = dst[:width_in_bytes]
|
||||
dst = dst[.. width_in_bytes]
|
||||
}
|
||||
|
||||
i = (this.dst_x as base.u64) * (bytes_per_pixel as base.u64)
|
||||
if i < dst.length() {
|
||||
j = (this.frame_rect_x1 as base.u64) * (bytes_per_pixel as base.u64)
|
||||
if (i <= j) and (j <= dst.length()) {
|
||||
dst = dst[i:j]
|
||||
dst = dst[i .. j]
|
||||
} else {
|
||||
dst = dst[i:]
|
||||
dst = dst[i ..]
|
||||
}
|
||||
n = this.swizzler.swizzle_interleaved!(
|
||||
dst:dst, dst_palette:this.dst_palette[:], src:src)
|
||||
dst:dst, dst_palette:this.dst_palette[..], src:src)
|
||||
|
||||
src_ri ~sat+= n
|
||||
this.dst_x ~sat+= (n & 0xFFFFFFFF) as base.u32
|
||||
|
||||
@@ -254,7 +254,7 @@ pri func decoder.read_from!(src base.io_reader) {
|
||||
// The final "8" is redundant semantically, but helps the
|
||||
// wuffs-c code generator recognize that both slices have the
|
||||
// same constant length, and hence produce efficient C code.
|
||||
this.output[o:o + 8].copy_from_slice!(s:this.suffixes[c][:8])
|
||||
this.output[o .. o + 8].copy_from_slice!(s:this.suffixes[c][.. 8])
|
||||
|
||||
if steps <= 0 {
|
||||
break
|
||||
@@ -338,7 +338,7 @@ pri func decoder.write_to?(dst base.io_writer) {
|
||||
if this.output_ri > this.output_wi {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
s = this.output[this.output_ri:this.output_wi]
|
||||
s = this.output[this.output_ri .. this.output_wi]
|
||||
n = args.dst.copy_from_slice!(s:s)
|
||||
if n == s.length() {
|
||||
this.output_ri = 0
|
||||
@@ -354,7 +354,7 @@ pub func decoder.flush!() slice base.u8 {
|
||||
var s slice base.u8
|
||||
|
||||
if this.output_ri <= this.output_wi {
|
||||
s = this.output[this.output_ri:this.output_wi]
|
||||
s = this.output[this.output_ri .. this.output_wi]
|
||||
}
|
||||
this.output_ri = 0
|
||||
this.output_wi = 0
|
||||
|
||||
Reference in new issue
Block a user