]> Cypherpunks.ru repositories - gostls13.git/commitdiff
all: remove unnecessary type conversions
authorMatthew Dempsky <mdempsky@google.com>
Fri, 15 Apr 2016 02:09:36 +0000 (19:09 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 15 Apr 2016 07:31:45 +0000 (07:31 +0000)
cmd and runtime were handled separately, and I'm intentionally skipped
syscall. This is the rest of the standard library.

CL generated mechanically with github.com/mdempsky/unconvert.

Change-Id: I9e0eff886974dedc37adb93f602064b83e469122
Reviewed-on: https://go-review.googlesource.com/22104
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

50 files changed:
src/archive/tar/reader.go
src/archive/tar/writer.go
src/bytes/reader.go
src/compress/bzip2/bzip2.go
src/compress/flate/huffman_bit_writer.go
src/compress/flate/reverse_bits.go
src/compress/lzw/writer.go
src/crypto/des/block.go
src/crypto/tls/handshake_messages.go
src/debug/dwarf/buf.go
src/debug/dwarf/line.go
src/debug/dwarf/typeunit.go
src/debug/elf/elf.go
src/debug/elf/file.go
src/debug/gosym/pclntab.go
src/debug/gosym/symtab.go
src/encoding/asn1/marshal.go
src/encoding/binary/binary.go
src/encoding/gob/encode.go
src/go/ast/ast.go
src/image/color/ycbcr.go
src/image/draw/draw.go
src/math/big/float.go
src/math/big/natconv.go
src/math/big/ratconv.go
src/net/interface_bsd.go
src/net/mail/message.go
src/net/parse.go
src/os/exec_windows.go
src/os/file_windows.go
src/os/stat_darwin.go
src/os/stat_dragonfly.go
src/os/stat_freebsd.go
src/os/stat_linux.go
src/os/stat_nacl.go
src/os/stat_netbsd.go
src/os/stat_openbsd.go
src/os/stat_plan9.go
src/os/stat_solaris.go
src/os/stat_windows.go
src/os/types_windows.go
src/reflect/type.go
src/reflect/value.go
src/regexp/onepass.go
src/strconv/extfloat.go
src/strings/reader.go
src/sync/pool.go
src/time/time.go
src/time/zoneinfo_windows.go
src/unicode/letter.go

index 741fe0152bf58ef3253798456b5e156febe3f4d6..b924eeb5687dd2db1192780c45d0ed401ff7b2ff 100644 (file)
@@ -306,7 +306,7 @@ func mergePAX(hdr *Header, headers map[string]string) error {
                        if err != nil {
                                return err
                        }
-                       hdr.Size = int64(size)
+                       hdr.Size = size
                default:
                        if strings.HasPrefix(k, paxXattr) {
                                if hdr.Xattrs == nil {
@@ -346,7 +346,7 @@ func parsePAXTime(t string) (time.Time, error) {
                        // Right truncate
                        nano_buf = nano_buf[:maxNanoSecondIntSize]
                }
-               nanoseconds, err = strconv.ParseInt(string(nano_buf), 10, 0)
+               nanoseconds, err = strconv.ParseInt(nano_buf, 10, 0)
                if err != nil {
                        return time.Time{}, err
                }
@@ -378,14 +378,14 @@ func parsePAX(r io.Reader) (map[string]string, error) {
                }
                sbuf = residual
 
-               keyStr := string(key)
+               keyStr := key
                if keyStr == paxGNUSparseOffset || keyStr == paxGNUSparseNumBytes {
                        // GNU sparse format 0.0 special key. Write to sparseMap instead of using the headers map.
                        sparseMap.WriteString(value)
                        sparseMap.Write([]byte{','})
                } else {
                        // Normal key. Set the value in the headers map.
-                       headers[keyStr] = string(value)
+                       headers[keyStr] = value
                }
        }
        if sparseMap.Len() != 0 {
index 600ee4be09c44d06285de55c6fc02ad8a84fc762..944b2d49529adf7dff3bf17daae9b11cfe3a8ac4 100644 (file)
@@ -278,7 +278,7 @@ func (tw *Writer) writeHeader(hdr *Header, allowPax bool) error {
                        return err
                }
        }
-       tw.nb = int64(hdr.Size)
+       tw.nb = hdr.Size
        tw.pad = (blockSize - (tw.nb % blockSize)) % blockSize
 
        _, tw.err = tw.w.Write(header)
index 7aa30578b321e30392ab1854abeacedc0f84ee5b..aa39890f3bd24f861019bc61aef80b25f7786d9c 100644 (file)
@@ -114,7 +114,7 @@ func (r *Reader) Seek(offset int64, whence int) (int64, error) {
        case 0:
                abs = offset
        case 1:
-               abs = int64(r.i) + offset
+               abs = r.i + offset
        case 2:
                abs = int64(len(r.s)) + offset
        default:
index 90e9aebab6236d71dc9b9b3b57077b861a352475..42788443bcf5ff59e3c5944a82ffe77d0638de95 100644 (file)
@@ -75,7 +75,7 @@ func (bz2 *reader) setup(needMagic bool) error {
        }
 
        bz2.fileCRC = 0
-       bz2.blockSize = 100 * 1000 * (int(level) - '0')
+       bz2.blockSize = 100 * 1000 * (level - '0')
        if bz2.blockSize > len(bz2.tt) {
                bz2.tt = make([]uint32, bz2.blockSize)
        }
@@ -293,7 +293,7 @@ func (bz2 *reader) readBlock() (err error) {
                if c >= numHuffmanTrees {
                        return StructuralError("tree index too large")
                }
-               treeIndexes[i] = uint8(mtfTreeDecoder.Decode(c))
+               treeIndexes[i] = mtfTreeDecoder.Decode(c)
        }
 
        // The list of symbols for the move-to-front transform is taken from
@@ -399,7 +399,7 @@ func (bz2 *reader) readBlock() (err error) {
                                return StructuralError("repeats past end of block")
                        }
                        for i := 0; i < repeat; i++ {
-                               b := byte(mtf.First())
+                               b := mtf.First()
                                bz2.tt[bufIndex] = uint32(b)
                                bz2.c[b]++
                                bufIndex++
@@ -420,7 +420,7 @@ func (bz2 *reader) readBlock() (err error) {
                // it's always referenced with a run-length of 1. Thus 0
                // doesn't need to be encoded and we have |v-1| in the next
                // line.
-               b := byte(mtf.Decode(int(v - 1)))
+               b := mtf.Decode(int(v - 1))
                if bufIndex >= bz2.blockSize {
                        return StructuralError("data exceeds block size")
                }
index 23f242f88ebc08eefbf0896d97f319d3f6ae86c4..d0206e59cf911881cfe19991cac5981008c5f258 100644 (file)
@@ -436,7 +436,7 @@ func (w *huffmanBitWriter) writeBlock(tokens []token, eof bool, input []byte) {
        }
        dynamicHeader := int64(3+5+5+4+(3*numCodegens)) +
                w.codegenEncoding.bitLength(w.codegenFreq[:]) +
-               int64(extraBits) +
+               extraBits +
                int64(w.codegenFreq[16]*2) +
                int64(w.codegenFreq[17]*3) +
                int64(w.codegenFreq[18]*7)
index c1a02720d1a9bcb2500c4156b2fc35a31e71b3bf..6b222900c1ec9deab163ca98e0bdcafd7c869fbb 100644 (file)
@@ -44,5 +44,5 @@ func reverseUint16(v uint16) uint16 {
 }
 
 func reverseBits(number uint16, bitLength byte) uint16 {
-       return reverseUint16(number << uint8(16-bitLength))
+       return reverseUint16(number << (16 - bitLength))
 }
index 7367c29651d772b6a6f5eeba0ba0af5ac1959d57..6ddb335f31523ba7b3d2ec45a37490663fa9a9fc 100644 (file)
@@ -119,7 +119,7 @@ func (e *encoder) incHi() error {
                if err := e.write(e, clear); err != nil {
                        return err
                }
-               e.width = uint(e.litWidth) + 1
+               e.width = e.litWidth + 1
                e.hi = clear + 1
                e.overflow = clear << 1
                for i := range e.table {
index 26355a22e714bebecc0a9c6243a1954e0dbf82d3..99338d62a6e0d35bdfb6bb61d44ce27d0151880d 100644 (file)
@@ -72,7 +72,7 @@ func init() {
                for i := 0; i < 4; i++ {
                        for j := 0; j < 16; j++ {
                                f := uint64(sBoxes[s][i][j]) << (4 * (7 - uint(s)))
-                               f = permuteBlock(uint64(f), permutationFunction[:])
+                               f = permuteBlock(f, permutationFunction[:])
                                feistelBox[s][16*i+j] = uint32(f)
                        }
                }
index 13d013a594b936b0cacc66cdcfa016a6ab6e9d8c..3f9a63b110a609c0e6ba8a663a2b7b640df3dcf3 100644 (file)
@@ -214,7 +214,7 @@ func (m *clientHelloMsg) marshal() []byte {
                z[4] = byte(l)
                z = z[5:]
                for _, pointFormat := range m.supportedPoints {
-                       z[0] = byte(pointFormat)
+                       z[0] = pointFormat
                        z = z[1:]
                }
        }
@@ -589,7 +589,7 @@ func (m *serverHelloMsg) marshal() []byte {
        z := x[39+len(m.sessionId):]
        z[0] = uint8(m.cipherSuite >> 8)
        z[1] = uint8(m.cipherSuite)
-       z[2] = uint8(m.compressionMethod)
+       z[2] = m.compressionMethod
 
        z = z[3:]
        if numExtensions > 0 {
index 7443043c1136d01e4b70fa362e8fad8b5ce3f94a..24d266db10738be0b2a6e9ae6277a381042ab9c2 100644 (file)
@@ -157,7 +157,7 @@ func (b *buf) addr() uint64 {
        case 4:
                return uint64(b.uint32())
        case 8:
-               return uint64(b.uint64())
+               return b.uint64()
        }
        b.error("unknown address size")
        return 0
index b3b91ade6250a6990d9fad238925801b7086d0de..ed82feef92b08137dae5f66a9ae8930206ea7992 100644 (file)
@@ -361,7 +361,7 @@ func (r *LineReader) step(entry *LineEntry) bool {
                // Special opcode [DWARF2 6.2.5.1, DWARF4 6.2.5.1]
                adjustedOpcode := opcode - r.opcodeBase
                r.advancePC(adjustedOpcode / r.lineRange)
-               lineDelta := r.lineBase + int(adjustedOpcode)%r.lineRange
+               lineDelta := r.lineBase + adjustedOpcode%r.lineRange
                r.state.Line += lineDelta
                goto emit
        }
index ed425473869e2b982c06feaa67fd200444a552eb..652e02d91725c7f5a419f710add28cf0701b996c 100644 (file)
@@ -76,7 +76,7 @@ func (d *Data) parseTypes(name string, types []byte) error {
                                data:   b.bytes(int(n - (b.off - hdroff))),
                                atable: atable,
                                asize:  int(asize),
-                               vers:   int(vers),
+                               vers:   vers,
                                is64:   dwarf64,
                        },
                        toff: Offset(toff),
@@ -101,7 +101,7 @@ func (d *Data) sigToType(sig uint64) (Type, error) {
 
        b := makeBuf(d, tu, tu.name, tu.off, tu.data)
        r := &typeUnitReader{d: d, tu: tu, b: b}
-       t, err := d.readType(tu.name, r, Offset(tu.toff), make(map[Offset]Type), nil)
+       t, err := d.readType(tu.name, r, tu.toff, make(map[Offset]Type), nil)
        if err != nil {
                return nil, err
        }
index af881c24950637fe89717c8039daaf685114c48f..3f43d4d896683994eb6e19bf218cfefb7d3e68f8 100644 (file)
@@ -2060,8 +2060,8 @@ type Rela32 struct {
        Addend int32  /* Addend. */
 }
 
-func R_SYM32(info uint32) uint32      { return uint32(info >> 8) }
-func R_TYPE32(info uint32) uint32     { return uint32(info & 0xff) }
+func R_SYM32(info uint32) uint32      { return info >> 8 }
+func R_TYPE32(info uint32) uint32     { return info & 0xff }
 func R_INFO32(sym, typ uint32) uint32 { return sym<<8 | typ }
 
 // ELF32 Symbol.
index 8fbf23fe5adaf9538fbf615a37db0d058bfc6d9e..c173ea933169995653bf31e691fc7542dd6cc0d6 100644 (file)
@@ -294,7 +294,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
                }
                f.Type = Type(hdr.Type)
                f.Machine = Machine(hdr.Machine)
-               f.Entry = uint64(hdr.Entry)
+               f.Entry = hdr.Entry
                if v := Version(hdr.Version); v != f.Version {
                        return nil, &FormatError{0, "mismatched ELF version", v}
                }
@@ -341,12 +341,12 @@ func NewFile(r io.ReaderAt) (*File, error) {
                        p.ProgHeader = ProgHeader{
                                Type:   ProgType(ph.Type),
                                Flags:  ProgFlag(ph.Flags),
-                               Off:    uint64(ph.Off),
-                               Vaddr:  uint64(ph.Vaddr),
-                               Paddr:  uint64(ph.Paddr),
-                               Filesz: uint64(ph.Filesz),
-                               Memsz:  uint64(ph.Memsz),
-                               Align:  uint64(ph.Align),
+                               Off:    ph.Off,
+                               Vaddr:  ph.Vaddr,
+                               Paddr:  ph.Paddr,
+                               Filesz: ph.Filesz,
+                               Memsz:  ph.Memsz,
+                               Align:  ph.Align,
                        }
                }
                p.sr = io.NewSectionReader(r, int64(p.Off), int64(p.Filesz))
@@ -374,8 +374,8 @@ func NewFile(r io.ReaderAt) (*File, error) {
                                Addr:      uint64(sh.Addr),
                                Offset:    uint64(sh.Off),
                                FileSize:  uint64(sh.Size),
-                               Link:      uint32(sh.Link),
-                               Info:      uint32(sh.Info),
+                               Link:      sh.Link,
+                               Info:      sh.Info,
                                Addralign: uint64(sh.Addralign),
                                Entsize:   uint64(sh.Entsize),
                        }
@@ -388,13 +388,13 @@ func NewFile(r io.ReaderAt) (*File, error) {
                        s.SectionHeader = SectionHeader{
                                Type:      SectionType(sh.Type),
                                Flags:     SectionFlag(sh.Flags),
-                               Offset:    uint64(sh.Off),
-                               FileSize:  uint64(sh.Size),
-                               Addr:      uint64(sh.Addr),
-                               Link:      uint32(sh.Link),
-                               Info:      uint32(sh.Info),
-                               Addralign: uint64(sh.Addralign),
-                               Entsize:   uint64(sh.Entsize),
+                               Offset:    sh.Off,
+                               FileSize:  sh.Size,
+                               Addr:      sh.Addr,
+                               Link:      sh.Link,
+                               Info:      sh.Info,
+                               Addralign: sh.Addralign,
+                               Entsize:   sh.Entsize,
                        }
                }
                s.sr = io.NewSectionReader(r, int64(s.Offset), int64(s.FileSize))
index 291f102262238351eefe8514be46ae3bf4c7f3da..e859d5aed5098f77675ba5a68e97af87e2a6be05 100644 (file)
@@ -207,8 +207,8 @@ func (t *LineTable) go12Funcs() []Func {
        funcs := make([]Func, n)
        for i := range funcs {
                f := &funcs[i]
-               f.Entry = uint64(t.uintptr(t.functab[2*i*int(t.ptrsize):]))
-               f.End = uint64(t.uintptr(t.functab[(2*i+2)*int(t.ptrsize):]))
+               f.Entry = t.uintptr(t.functab[2*i*int(t.ptrsize):])
+               f.End = t.uintptr(t.functab[(2*i+2)*int(t.ptrsize):])
                info := t.Data[t.uintptr(t.functab[(2*i+1)*int(t.ptrsize):]):]
                f.LineTable = t
                f.FrameSize = int(t.binary.Uint32(info[t.ptrsize+2*4:]))
index 49e154fd8ef305b06ac0eec97c13604ceed19e94..c8fa9a0b38417fbb0bcbbb7e5ab6165d3f6b86c8 100644 (file)
@@ -294,8 +294,8 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, error) {
                t.Syms = t.Syms[0 : n+1]
                ts := &t.Syms[n]
                ts.Type = s.typ
-               ts.Value = uint64(s.value)
-               ts.GoType = uint64(s.gotype)
+               ts.Value = s.value
+               ts.GoType = s.gotype
                switch s.typ {
                default:
                        // rewrite name to use . instead of Â· (c2 b7)
index 2b796c4e75d108ade665452786be9ce5f067be2e..30797ef0996e547415977d29110a259d7b16c263 100644 (file)
@@ -315,9 +315,9 @@ func marshalUTCTime(out *forkableWriter, t time.Time) (err error) {
 
        switch {
        case 1950 <= year && year < 2000:
-               err = marshalTwoDigits(out, int(year-1900))
+               err = marshalTwoDigits(out, year-1900)
        case 2000 <= year && year < 2050:
-               err = marshalTwoDigits(out, int(year-2000))
+               err = marshalTwoDigits(out, year-2000)
        default:
                return StructuralError{"cannot represent time as UTCTime"}
        }
@@ -435,7 +435,7 @@ func marshalBody(out *forkableWriter, value reflect.Value, params fieldParameter
                        return out.WriteByte(0)
                }
        case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
-               return marshalInt64(out, int64(v.Int()))
+               return marshalInt64(out, v.Int())
        case reflect.Struct:
                t := v.Type()
 
index ada5768695681be6d46a52d0284d2601d57bdb1a..46c6add062a4423cf651ea5983ae6a3640847e8a 100644 (file)
@@ -269,7 +269,7 @@ func Write(w io.Writer, order ByteOrder, data interface{}) error {
                case *uint8:
                        b[0] = *v
                case uint8:
-                       b[0] = byte(v)
+                       b[0] = v
                case []uint8:
                        bs = v
                case *int16:
index 2b3a556eac2dd29b153dccf253ea7ed7e2061dbb..50cd6adb463c40da17d63419fa0842d468a68b5c 100644 (file)
@@ -127,7 +127,7 @@ func (state *encoderState) encodeInt(i int64) {
        } else {
                x = uint64(i << 1)
        }
-       state.encodeUint(uint64(x))
+       state.encodeUint(x)
 }
 
 // encOp is the signature of an encoding operator for a given type.
index 5ab4283826ba2de45e96a5ee87fd8e14feab23a7..cca2d48bbde90ad087755310d7494bb4b498812c 100644 (file)
@@ -99,7 +99,7 @@ func (g *CommentGroup) Text() string {
        }
        comments := make([]string, len(g.List))
        for i, c := range g.List {
-               comments[i] = string(c.Text)
+               comments[i] = c.Text
        }
 
        lines := make([]string, 0, 10) // most comments are less than 10 lines
index d2c5b569a7c8d9930f4117cf16db5c4df5dec8ac..2e985fece1ef342406254153e336df5fecfaf561 100644 (file)
@@ -237,10 +237,10 @@ func RGBToCMYK(r, g, b uint8) (uint8, uint8, uint8, uint8) {
 
 // CMYKToRGB converts a CMYK quadruple to an RGB triple.
 func CMYKToRGB(c, m, y, k uint8) (uint8, uint8, uint8) {
-       w := uint32(0xffff - uint32(k)*0x101)
-       r := uint32(0xffff-uint32(c)*0x101) * w / 0xffff
-       g := uint32(0xffff-uint32(m)*0x101) * w / 0xffff
-       b := uint32(0xffff-uint32(y)*0x101) * w / 0xffff
+       w := 0xffff - uint32(k)*0x101
+       r := (0xffff - uint32(c)*0x101) * w / 0xffff
+       g := (0xffff - uint32(m)*0x101) * w / 0xffff
+       b := (0xffff - uint32(y)*0x101) * w / 0xffff
        return uint8(r >> 8), uint8(g >> 8), uint8(b >> 8)
 }
 
@@ -256,11 +256,11 @@ func (c CMYK) RGBA() (uint32, uint32, uint32, uint32) {
        // This code is a copy of the CMYKToRGB function above, except that it
        // returns values in the range [0, 0xffff] instead of [0, 0xff].
 
-       w := uint32(0xffff - uint32(c.K)*0x101)
-       r := uint32(0xffff-uint32(c.C)*0x101) * w / 0xffff
-       g := uint32(0xffff-uint32(c.M)*0x101) * w / 0xffff
-       b := uint32(0xffff-uint32(c.Y)*0x101) * w / 0xffff
-       return uint32(r), uint32(g), uint32(b), 0xffff
+       w := 0xffff - uint32(c.K)*0x101
+       r := (0xffff - uint32(c.C)*0x101) * w / 0xffff
+       g := (0xffff - uint32(c.M)*0x101) * w / 0xffff
+       b := (0xffff - uint32(c.Y)*0x101) * w / 0xffff
+       return r, g, b, 0xffff
 }
 
 // CMYKModel is the Model for CMYK colors.
index 94e3575663676d09088158c1e1b80af7caa2db25..6a16cd39cf8ef2b6e474293b51fe29706d496d90 100644 (file)
@@ -634,10 +634,10 @@ func drawPaletted(dst Image, r image.Rectangle, src image.Image, sp image.Point,
                                if !floydSteinberg {
                                        continue
                                }
-                               er -= int32(palette[bestIndex][0])
-                               eg -= int32(palette[bestIndex][1])
-                               eb -= int32(palette[bestIndex][2])
-                               ea -= int32(palette[bestIndex][3])
+                               er -= palette[bestIndex][0]
+                               eg -= palette[bestIndex][1]
+                               eb -= palette[bestIndex][2]
+                               ea -= palette[bestIndex][3]
 
                        } else {
                                out.R = uint16(er)
index 4b8ad388d3966239f4670020b414349c2dacc148..7a9c2b3dfb2b40191193210f301eb5ba2d86e55f 100644 (file)
@@ -1008,9 +1008,9 @@ func (x *Float) Float64() (float64, Accuracy) {
                if r.form == inf || e > emax {
                        // overflow
                        if x.neg {
-                               return float64(math.Inf(-1)), Below
+                               return math.Inf(-1), Below
                        }
-                       return float64(math.Inf(+1)), Above
+                       return math.Inf(+1), Above
                }
                // e <= emax
 
index d2ce667fb602c5c695414e1219dbf166fb4719f1..e216bd288ccd2c4432d20518962c6b5a51c9a850 100644 (file)
@@ -302,7 +302,7 @@ func (x nat) itoa(neg bool, base int) []byte {
                }
 
        } else {
-               bb, ndigits := maxPow(Word(b))
+               bb, ndigits := maxPow(b)
 
                // construct table of successive squares of bb*leafSize to use in subdivisions
                // result (table != nil) <=> (len(x) > leafSize > 0)
index 57df124e88fc97b25a21895360ca0c492153b0d0..7c127f8585751e09c334c044a31d00e95f7ab49b 100644 (file)
@@ -178,7 +178,7 @@ func scanExponent(r io.ByteScanner, binExpOk bool) (exp int64, base int, err err
                        }
                        break // i > 0
                }
-               digits = append(digits, byte(ch))
+               digits = append(digits, ch)
        }
        // i > 0 => we have at least one digit
 
index b173fbcefc20f143765f512cb13344bf48770431..17c6dd3dcd69df12ffbe5bd38d26add416961153 100644 (file)
@@ -61,13 +61,13 @@ func newLink(m *syscall.InterfaceMessage) (*Interface, error) {
                m.Data = m.Data[unsafe.Offsetof(sa.Data):]
                var name [syscall.IFNAMSIZ]byte
                for i := 0; i < int(sa.Nlen); i++ {
-                       name[i] = byte(m.Data[i])
+                       name[i] = m.Data[i]
                }
                ifi.Name = string(name[:sa.Nlen])
                ifi.MTU = int(m.Header.Data.Mtu)
                addr := make([]byte, sa.Alen)
                for i := 0; i < int(sa.Alen); i++ {
-                       addr[i] = byte(m.Data[int(sa.Nlen)+i])
+                       addr[i] = m.Data[int(sa.Nlen)+i]
                }
                ifi.HardwareAddr = addr[:sa.Alen]
        }
index 9e3a103a4f76c524bbce364aebd752c9b51975a1..b40a314e33da330b448b5687f7eb063dd0a28bd1 100644 (file)
@@ -477,7 +477,7 @@ func (p *addrParser) consumeAtom(dot bool, permissive bool) (atom string, err er
        if i < p.len() && p.s[i] > 127 {
                return "", errNonASCII
        }
-       atom, p.s = string(p.s[:i]), p.s[i:]
+       atom, p.s = p.s[:i], p.s[i:]
        if !permissive {
                if strings.HasPrefix(atom, ".") {
                        return "", errors.New("mail: leading dot in atom")
index eaaa1edf3012cd96e38d01a25ac21bf623c2ab0c..ed82a7769b3176bd95bd54868b105a47021588a4 100644 (file)
@@ -105,14 +105,14 @@ func splitAtBytes(s string, t string) []string {
        for i := 0; i < len(s); i++ {
                if byteIndex(t, s[i]) >= 0 {
                        if last < i {
-                               a[n] = string(s[last:i])
+                               a[n] = s[last:i]
                                n++
                        }
                        last = i + 1
                }
        }
        if last < len(s) {
-               a[n] = string(s[last:])
+               a[n] = s[last:]
                n++
        }
        return a[0:n]
index 3264271b2e95b6682c754dd51911d0a8d420db5c..72b5a931999b2d86722731fcbfd2a27de608a08e 100644 (file)
@@ -104,7 +104,7 @@ func init() {
        defer syscall.LocalFree(syscall.Handle(uintptr(unsafe.Pointer(argv))))
        Args = make([]string, argc)
        for i, v := range (*argv)[:argc] {
-               Args[i] = string(syscall.UTF16ToString((*v)[:]))
+               Args[i] = syscall.UTF16ToString((*v)[:])
        }
 }
 
index 7d04477d42ec111bec9f3817e8d2c5ea283374dc..137f24a0a95979dabcca244e573e5ceae6c2b1aa 100644 (file)
@@ -181,9 +181,9 @@ func (file *file) close() error {
        }
        var e error
        if file.isdir() {
-               e = syscall.FindClose(syscall.Handle(file.fd))
+               e = syscall.FindClose(file.fd)
        } else {
-               e = syscall.CloseHandle(syscall.Handle(file.fd))
+               e = syscall.CloseHandle(file.fd)
        }
        var err error
        if e != nil {
@@ -216,7 +216,7 @@ func (file *File) readdir(n int) (fi []FileInfo, err error) {
        d := &file.dirinfo.data
        for n != 0 && !file.dirinfo.isempty {
                if file.dirinfo.needdata {
-                       e := syscall.FindNextFile(syscall.Handle(file.fd), d)
+                       e := syscall.FindNextFile(file.fd, d)
                        if e != nil {
                                if e == syscall.ERROR_NO_MORE_FILES {
                                        break
@@ -230,7 +230,7 @@ func (file *File) readdir(n int) (fi []FileInfo, err error) {
                        }
                }
                file.dirinfo.needdata = true
-               name := string(syscall.UTF16ToString(d.FileName[0:]))
+               name := syscall.UTF16ToString(d.FileName[0:])
                if name == "." || name == ".." { // Useless names
                        continue
                }
@@ -288,7 +288,7 @@ func (f *File) readConsole(b []byte) (n int, err error) {
                        }
                        wchars := make([]uint16, nwc)
                        pwc := &wchars[0]
-                       nwc, err = windows.MultiByteToWideChar(acp, 2, pmb, int32(nmb), pwc, int32(nwc))
+                       nwc, err = windows.MultiByteToWideChar(acp, 2, pmb, int32(nmb), pwc, nwc)
                        if err != nil {
                                return 0, err
                        }
@@ -335,7 +335,7 @@ func (f *File) pread(b []byte, off int64) (n int, err error) {
                Offset:     uint32(off),
        }
        var done uint32
-       e = syscall.ReadFile(syscall.Handle(f.fd), b, &done, &o)
+       e = syscall.ReadFile(f.fd, b, &done, &o)
        if e != nil {
                if e == syscall.ERROR_HANDLE_EOF {
                        // end of file
@@ -415,7 +415,7 @@ func (f *File) pwrite(b []byte, off int64) (n int, err error) {
                Offset:     uint32(off),
        }
        var done uint32
-       e = syscall.WriteFile(syscall.Handle(f.fd), b, &done, &o)
+       e = syscall.WriteFile(f.fd, b, &done, &o)
        if e != nil {
                return 0, e
        }
index 9dc7a99fb7f52dad9bde085f4ebc8884c53237b4..74214cefa446ea43a99bb3a99c482dceeb66e81c 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtimespec)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
index 69e63230eb304b4294fbd79e88a75cfe8d3b61bd..217bc6726d22ccfaf900efb4ae527c478d3c0ff8 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtim)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
@@ -42,7 +42,7 @@ func fillFileStatFromSys(fs *fileStat, name string) {
 }
 
 func timespecToTime(ts syscall.Timespec) time.Time {
-       return time.Unix(int64(ts.Sec), int64(ts.Nsec))
+       return time.Unix(ts.Sec, ts.Nsec)
 }
 
 // For testing.
index e9d38aa7229b4de7ae13c6271c0be1ec7224bdcb..bab4ffa7984cf961a816fac9f46ad97860e429b1 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtimespec)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
index 69e63230eb304b4294fbd79e88a75cfe8d3b61bd..d36afa9ffd5e74c5116e6d638be6bc3536e24a01 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtim)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
index d3bed14e430f68e8dfbd7ac8e3b0c75b265b362b..0c53f2faa43781337abaf22be54d7b941460f7c0 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtime, fs.sys.MtimeNsec)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
index e9d38aa7229b4de7ae13c6271c0be1ec7224bdcb..11ebcacab85f1709cd9a78c1ddbe5d16d55f14ed 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtimespec)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
@@ -42,7 +42,7 @@ func fillFileStatFromSys(fs *fileStat, name string) {
 }
 
 func timespecToTime(ts syscall.Timespec) time.Time {
-       return time.Unix(int64(ts.Sec), int64(ts.Nsec))
+       return time.Unix(ts.Sec, int64(ts.Nsec))
 }
 
 // For testing.
index 69e63230eb304b4294fbd79e88a75cfe8d3b61bd..9df2d7f7737efc297db481a6287ef9a6f132efa0 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtim)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
@@ -42,7 +42,7 @@ func fillFileStatFromSys(fs *fileStat, name string) {
 }
 
 func timespecToTime(ts syscall.Timespec) time.Time {
-       return time.Unix(int64(ts.Sec), int64(ts.Nsec))
+       return time.Unix(ts.Sec, int64(ts.Nsec))
 }
 
 // For testing.
index a2df5fe1395b92c2bcdabc1d6261dfb6a5c8995c..96f056c1117b5e7d7525d6d9f2919923083db682 100644 (file)
@@ -20,7 +20,7 @@ func sameFile(fs1, fs2 *fileStat) bool {
 func fileInfoFromStat(d *syscall.Dir) FileInfo {
        fs := &fileStat{
                name:    d.Name,
-               size:    int64(d.Length),
+               size:    d.Length,
                modTime: time.Unix(int64(d.Mtime), 0),
                sys:     d,
        }
index 69e63230eb304b4294fbd79e88a75cfe8d3b61bd..217bc6726d22ccfaf900efb4ae527c478d3c0ff8 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 func fillFileStatFromSys(fs *fileStat, name string) {
        fs.name = basename(name)
-       fs.size = int64(fs.sys.Size)
+       fs.size = fs.sys.Size
        fs.modTime = timespecToTime(fs.sys.Mtim)
        fs.mode = FileMode(fs.sys.Mode & 0777)
        switch fs.sys.Mode & syscall.S_IFMT {
@@ -42,7 +42,7 @@ func fillFileStatFromSys(fs *fileStat, name string) {
 }
 
 func timespecToTime(ts syscall.Timespec) time.Time {
-       return time.Unix(int64(ts.Sec), int64(ts.Nsec))
+       return time.Unix(ts.Sec, ts.Nsec)
 }
 
 // For testing.
index b8f97ad60a8e16097fa3f1152567bd720b61e625..e55eeb0fdd67be5fdce25999d4c5db01871ac6e6 100644 (file)
@@ -35,7 +35,7 @@ func (file *File) Stat() (FileInfo, error) {
        }
 
        var d syscall.ByHandleFileInformation
-       err = syscall.GetFileInformationByHandle(syscall.Handle(file.fd), &d)
+       err = syscall.GetFileInformationByHandle(file.fd, &d)
        if err != nil {
                return nil, &PathError{"GetFileInformationByHandle", file.name, err}
        }
index 900d444b0e012c0a6da81751bad50203eb98e778..ad4e863fcbbd74eb23819b86db9f2fd9068e10ae 100644 (file)
@@ -73,7 +73,7 @@ func (fs *fileStat) loadFileId() error {
        }
        defer syscall.CloseHandle(h)
        var i syscall.ByHandleFileInformation
-       err = syscall.GetFileInformationByHandle(syscall.Handle(h), &i)
+       err = syscall.GetFileInformationByHandle(h, &i)
        if err != nil {
                return err
        }
index 3c7affcd7f1f0f6098d07577288d8bb196bd533f..b8c778cc2b6382cd71b3641a332c89e234dd41fe 100644 (file)
@@ -967,7 +967,7 @@ func (t *rtype) Out(i int) Type {
 }
 
 func (t *funcType) in() []*rtype {
-       uadd := uintptr(unsafe.Sizeof(*t))
+       uadd := unsafe.Sizeof(*t)
        if t.tflag&tflagUncommon != 0 {
                uadd += unsafe.Sizeof(uncommonType{})
        }
@@ -975,7 +975,7 @@ func (t *funcType) in() []*rtype {
 }
 
 func (t *funcType) out() []*rtype {
-       uadd := uintptr(unsafe.Sizeof(*t))
+       uadd := unsafe.Sizeof(*t)
        if t.tflag&tflagUncommon != 0 {
                uadd += unsafe.Sizeof(uncommonType{})
        }
index d72c14e9e1492fb2e72bfe77648455225eab47d2..d4d317436a423cc5eabf7e50fa309068e3ff58f5 100644 (file)
@@ -666,7 +666,7 @@ func (v Value) Cap() int {
        case Array:
                return v.typ.Len()
        case Chan:
-               return int(chancap(v.pointer()))
+               return chancap(v.pointer())
        case Slice:
                // Slice is always bigger than a word; assume flagIndir.
                return (*sliceHeader)(v.ptr).Cap
@@ -885,7 +885,7 @@ func (v Value) Int() int64 {
        case Int32:
                return int64(*(*int32)(p))
        case Int64:
-               return int64(*(*int64)(p))
+               return *(*int64)(p)
        }
        panic(&ValueError{"reflect.Value.Int", v.kind()})
 }
@@ -1436,7 +1436,7 @@ func (v Value) SetCap(n int) {
        v.mustBeAssignable()
        v.mustBe(Slice)
        s := (*sliceHeader)(v.ptr)
-       if n < int(s.Len) || n > int(s.Cap) {
+       if n < s.Len || n > s.Cap {
                panic("reflect: slice capacity out of range in SetCap")
        }
        s.Cap = n
@@ -1538,7 +1538,7 @@ func (v Value) Slice(i, j int) Value {
        case Slice:
                typ = (*sliceType)(unsafe.Pointer(v.typ))
                s := (*sliceHeader)(v.ptr)
-               base = unsafe.Pointer(s.Data)
+               base = s.Data
                cap = s.Cap
 
        case String:
@@ -1710,7 +1710,7 @@ func (v Value) Uint() uint64 {
        case Uint32:
                return uint64(*(*uint32)(p))
        case Uint64:
-               return uint64(*(*uint64)(p))
+               return *(*uint64)(p)
        case Uintptr:
                return uint64(*(*uintptr)(p))
        }
@@ -2267,13 +2267,13 @@ func makeInt(f flag, bits uint64, t Type) Value {
        ptr := unsafe_New(typ)
        switch typ.size {
        case 1:
-               *(*uint8)(unsafe.Pointer(ptr)) = uint8(bits)
+               *(*uint8)(ptr) = uint8(bits)
        case 2:
-               *(*uint16)(unsafe.Pointer(ptr)) = uint16(bits)
+               *(*uint16)(ptr) = uint16(bits)
        case 4:
-               *(*uint32)(unsafe.Pointer(ptr)) = uint32(bits)
+               *(*uint32)(ptr) = uint32(bits)
        case 8:
-               *(*uint64)(unsafe.Pointer(ptr)) = bits
+               *(*uint64)(ptr) = bits
        }
        return Value{typ, ptr, f | flagIndir | flag(typ.Kind())}
 }
@@ -2285,9 +2285,9 @@ func makeFloat(f flag, v float64, t Type) Value {
        ptr := unsafe_New(typ)
        switch typ.size {
        case 4:
-               *(*float32)(unsafe.Pointer(ptr)) = float32(v)
+               *(*float32)(ptr) = float32(v)
        case 8:
-               *(*float64)(unsafe.Pointer(ptr)) = v
+               *(*float64)(ptr) = v
        }
        return Value{typ, ptr, f | flagIndir | flag(typ.Kind())}
 }
@@ -2299,9 +2299,9 @@ func makeComplex(f flag, v complex128, t Type) Value {
        ptr := unsafe_New(typ)
        switch typ.size {
        case 8:
-               *(*complex64)(unsafe.Pointer(ptr)) = complex64(v)
+               *(*complex64)(ptr) = complex64(v)
        case 16:
-               *(*complex128)(unsafe.Pointer(ptr)) = v
+               *(*complex128)(ptr) = v
        }
        return Value{typ, ptr, f | flagIndir | flag(typ.Kind())}
 }
index 5b82f9666e74485517fb2912a1029e27500725bd..49919548201a66f9cc7af47bbc8279f14196c3f7 100644 (file)
@@ -450,7 +450,7 @@ func makeOnePass(p *onePassProg) *onePassProg {
        for !instQueue.empty() {
                visitQueue.clear()
                pc := instQueue.next()
-               if !check(uint32(pc), m) {
+               if !check(pc, m) {
                        p = notOnePass
                        break
                }
index 019b4eebdc970a2da78601f54c7579d0d63d8336..7033e96c39e4908e1f48db2ea2a61e1575d46368 100644 (file)
@@ -311,9 +311,9 @@ func (f *extFloat) AssignDecimal(mantissa uint64, exp10 int, neg bool, trunc boo
        var extrabits uint
        if f.exp <= denormalExp {
                // f.mant * 2^f.exp is smaller than 2^(flt.bias+1).
-               extrabits = uint(63 - flt.mantbits + 1 + uint(denormalExp-f.exp))
+               extrabits = 63 - flt.mantbits + 1 + uint(denormalExp-f.exp)
        } else {
-               extrabits = uint(63 - flt.mantbits)
+               extrabits = 63 - flt.mantbits
        }
 
        halfway := uint64(1) << (extrabits - 1)
index 737873c0992903153c32bed3410daaa650c6d918..74eed4d57488b553fb7bc32f150dbaf7dfedea4f 100644 (file)
@@ -113,7 +113,7 @@ func (r *Reader) Seek(offset int64, whence int) (int64, error) {
        case 0:
                abs = offset
        case 1:
-               abs = int64(r.i) + offset
+               abs = r.i + offset
        case 2:
                abs = int64(len(r.s)) + offset
        default:
index 4fb1a1af9d988c0226f804e6262f2558fcef5cd6..2acf505f3c96b90da8c60ddded56540bc4638239 100644 (file)
@@ -179,8 +179,8 @@ func (p *Pool) pinSlow() *poolLocal {
        // If GOMAXPROCS changes between GCs, we re-allocate the array and lose the old one.
        size := runtime.GOMAXPROCS(0)
        local := make([]poolLocal, size)
-       atomic.StorePointer((*unsafe.Pointer)(&p.local), unsafe.Pointer(&local[0])) // store-release
-       atomic.StoreUintptr(&p.localSize, uintptr(size))                            // store-release
+       atomic.StorePointer(&p.local, unsafe.Pointer(&local[0])) // store-release
+       atomic.StoreUintptr(&p.localSize, uintptr(size))         // store-release
        return &local[pid]
 }
 
index 4b9a0db7302cf15264acf5310160595c6921612f..92d635eec5099ebdadaac0f97c5fe1ee56d1850a 100644 (file)
@@ -606,7 +606,7 @@ func (d Duration) Hours() float64 {
 // Add returns the time t+d.
 func (t Time) Add(d Duration) Time {
        t.sec += int64(d / 1e9)
-       nsec := int32(t.nsec) + int32(d%1e9)
+       nsec := t.nsec + int32(d%1e9)
        if nsec >= 1e9 {
                t.sec++
                nsec -= 1e9
@@ -623,7 +623,7 @@ func (t Time) Add(d Duration) Time {
 // will be returned.
 // To compute t-d for a duration d, use t.Add(-d).
 func (t Time) Sub(u Time) Duration {
-       d := Duration(t.sec-u.sec)*Second + Duration(int32(t.nsec)-int32(u.nsec))
+       d := Duration(t.sec-u.sec)*Second + Duration(t.nsec-u.nsec)
        // Check for overflow or underflow.
        switch {
        case u.Add(d).Equal(t):
@@ -1125,7 +1125,7 @@ func (t Time) Round(d Duration) Time {
 // but it's still here in case we change our minds.
 func div(t Time, d Duration) (qmod2 int, r Duration) {
        neg := false
-       nsec := int32(t.nsec)
+       nsec := t.nsec
        if t.sec < 0 {
                // Operate on absolute value.
                neg = true
@@ -1159,7 +1159,7 @@ func div(t Time, d Duration) (qmod2 int, r Duration) {
                tmp := (sec >> 32) * 1e9
                u1 := tmp >> 32
                u0 := tmp << 32
-               tmp = uint64(sec&0xFFFFFFFF) * 1e9
+               tmp = (sec & 0xFFFFFFFF) * 1e9
                u0x, u0 := u0, u0+tmp
                if u0 < u0x {
                        u1++
index bcb8ccd56326264979fc7a7ab251bfcf8d8a1383..c753119d5db76530d7aaf24a1dca95063f13c701 100644 (file)
@@ -83,7 +83,7 @@ func extractCAPS(desc string) string {
        var short []rune
        for _, c := range desc {
                if 'A' <= c && c <= 'Z' {
-                       short = append(short, rune(c))
+                       short = append(short, c)
                }
        }
        return string(short)
index 8443ee51a2f210bf509028aff980d905441fa402..ffa083eb57888e475847ba8777fb0f316d1add61 100644 (file)
@@ -217,7 +217,7 @@ func to(_case int, r rune, caseRange []CaseRange) rune {
                m := lo + (hi-lo)/2
                cr := caseRange[m]
                if rune(cr.Lo) <= r && r <= rune(cr.Hi) {
-                       delta := rune(cr.Delta[_case])
+                       delta := cr.Delta[_case]
                        if delta > MaxRune {
                                // In an Upper-Lower sequence, which always starts with
                                // an UpperCase letter, the real deltas always look like: