Rename [i:j] to [i .. j], the same as Rust

This commit is contained in:
Nigel Tao committed 2019-10-12 21:14:18 +11:00
1 parent 7872a8893b
commit a9ea63ff06
16 files changed
+55 -50

No files matched your search

+4 -4
View File
@@ -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
+2 -2
View File
@@ -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
}
+2 -2
View File
@@ -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