diff --git a/codec_fixed.go b/codec_fixed.go index 887defd..d6a642b 100644 --- a/codec_fixed.go +++ b/codec_fixed.go @@ -115,13 +115,13 @@ type fixedCodec struct { } func (c *fixedCodec) Decode(ptr unsafe.Pointer, r *Reader) { - for i := 0; i < c.arrayType.Len(); i++ { + for i := range c.arrayType.Len() { c.arrayType.UnsafeSetIndex(ptr, i, reflect2.PtrOf(r.readByte())) } } func (c *fixedCodec) Encode(ptr unsafe.Pointer, w *Writer) { - for i := 0; i < c.arrayType.Len(); i++ { + for i := range c.arrayType.Len() { bytePtr := c.arrayType.UnsafeGetIndex(ptr, i) w.writeByte(*((*byte)(bytePtr))) } diff --git a/codec_map.go b/codec_map.go index ceefa00..18c7de1 100644 --- a/codec_map.go +++ b/codec_map.go @@ -67,7 +67,7 @@ func (d *mapDecoder) Decode(ptr unsafe.Pointer, r *Reader) { break } - for i := int64(0); i < l; i++ { + for range l { keyPtr := reflect2.PtrOf(r.ReadString()) elemPtr := d.elemType.UnsafeNew() d.decoder.Decode(elemPtr, r) @@ -115,7 +115,7 @@ func (d *mapDecoderUnmarshaler) Decode(ptr unsafe.Pointer, r *Reader) { break } - for i := int64(0); i < l; i++ { + for range l { keyPtr := d.keyType.UnsafeNew() keyObj := d.keyType.UnsafeIndirect(keyPtr) if reflect2.IsNil(keyObj) { diff --git a/codec_record.go b/codec_record.go index d07a4aa..67562b7 100644 --- a/codec_record.go +++ b/codec_record.go @@ -465,7 +465,7 @@ func describeStruct(tagKey string, typ reflect2.Type) *structDescriptor { } visited[rtype] = true - for i := 0; i < f.anon.NumField(); i++ { + for i := range f.anon.NumField() { field := f.anon.Field(i).(*reflect2.UnsafeStructField) isUnexported := field.PkgPath() != "" diff --git a/codec_skip.go b/codec_skip.go index 965efe8..3be0dd6 100644 --- a/codec_skip.go +++ b/codec_skip.go @@ -152,7 +152,7 @@ func (d *sliceSkipDecoder) Decode(_ unsafe.Pointer, r *Reader) { continue } - for i := 0; i < int(l); i++ { + for range l { d.decoder.Decode(nil, r) } } @@ -183,7 +183,7 @@ func (d *mapSkipDecoder) Decode(_ unsafe.Pointer, r *Reader) { continue } - for i := 0; i < int(l); i++ { + for range l { r.SkipString() d.decoder.Decode(nil, r) } diff --git a/pkg/crc64/crc64.go b/pkg/crc64/crc64.go index 1506077..889e4b3 100644 --- a/pkg/crc64/crc64.go +++ b/pkg/crc64/crc64.go @@ -21,9 +21,9 @@ type Table [256]uint64 func makeTable() *Table { t := new(Table) - for i := 0; i < 256; i++ { + for i := range 256 { fp := uint64(i) - for j := 0; j < 8; j++ { + for range 8 { fp = (fp >> 1) ^ (Empty & -(fp & 1)) } t[i] = fp @@ -68,7 +68,7 @@ func (d *digest) Reset() { // Write accumulatively adds the given data to the checksum. func (d *digest) Write(p []byte) (n int, err error) { - for i := 0; i < len(p); i++ { + for i := range p { d.crc = (d.crc >> 8) ^ d.tab[(int)(byte(d.crc)^p[i])&0xff] } diff --git a/reader_generic.go b/reader_generic.go index b75d240..32d341c 100644 --- a/reader_generic.go +++ b/reader_generic.go @@ -133,7 +133,7 @@ func (r *Reader) ReadArrayCB(fn func(*Reader) bool) { if l == 0 { break } - for i := 0; i < int(l); i++ { + for range l { fn(r) } } @@ -147,7 +147,7 @@ func (r *Reader) ReadMapCB(fn func(*Reader, string) bool) { break } - for i := 0; i < int(l); i++ { + for range l { field := r.ReadString() fn(r, field) } diff --git a/schema.go b/schema.go index a153768..0d82f7a 100644 --- a/schema.go +++ b/schema.go @@ -1735,7 +1735,7 @@ func isValidDefaultBytes(def string) ([]byte, bool) { runes := []rune(def) l := len(runes) b := make([]byte, l) - for i := 0; i < l; i++ { + for i := range l { if runes[i] < 0 || runes[i] > 255 { return nil, false }