lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 0da4dbe2 authored by Matthew Dempsky's avatar Matthew Dempsky

all: remove unnecessary type conversions

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