package jx
var digits []uint32
func init () {
digits = make ([]uint32 , 1000 )
for i := uint32 (0 ); i < 1000 ; i ++ {
digits [i ] = (((i / 100 ) + '0' ) << 16 ) + ((((i / 10 ) % 10 ) + '0' ) << 8 ) + i %10 + '0'
if i < 10 {
digits [i ] += 2 << 24
} else if i < 100 {
digits [i ] += 1 << 24
}
}
}
func writeFirstBuf (w *Writer , v uint32 ) bool {
r := make ([]byte , 0 , 4 )
start := v >> 24
if start == 0 {
r = append (r , byte (v >>16 ), byte (v >>8 ))
} else if start == 1 {
r = append (r , byte (v >>8 ))
}
r = append (r , byte (v ))
return writeStreamBytes (w , r ...)
}
func writeBuf (w *Writer , v uint32 ) bool {
return writeStreamBytes (w , byte (v >>16 ), byte (v >>8 ), byte (v ))
}
func (w *Writer ) UInt16 (v uint16 ) (fail bool ) {
q0 := v
q1 := q0 / 1000
if q1 == 0 {
fail = fail || writeFirstBuf (w , digits [q0 ])
return fail
}
r1 := q0 - q1 *1000
fail = fail || writeFirstBuf (w , digits [q1 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
func (e *Encoder ) UInt16 (v uint16 ) bool {
return e .comma () || e .w .UInt16 (v )
}
func (w *Writer ) Int16 (v int16 ) (fail bool ) {
var val uint16
if v < 0 {
val = uint16 (-v )
fail = w .byte ('-' )
} else {
val = uint16 (v )
}
return fail || w .UInt16 (val )
}
func (e *Encoder ) Int16 (v int16 ) bool {
return e .comma () || e .w .Int16 (v )
}
func (w *Writer ) UInt32 (v uint32 ) (fail bool ) {
q0 := v
q1 := q0 / 1000
if q1 == 0 {
fail = fail || writeFirstBuf (w , digits [q0 ])
return fail
}
r1 := q0 - q1 *1000
q2 := q1 / 1000
if q2 == 0 {
fail = fail || writeFirstBuf (w , digits [q1 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
r2 := q1 - q2 *1000
q3 := q2 / 1000
if q3 == 0 {
fail = fail || writeFirstBuf (w , digits [q2 ])
fail = fail || writeBuf (w , digits [r2 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
r3 := q2 - q3 *1000
fail = fail || writeFirstBuf (w , digits [q3 ])
fail = fail || writeBuf (w , digits [r3 ])
fail = fail || writeBuf (w , digits [r2 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
func (e *Encoder ) UInt32 (v uint32 ) bool {
return e .comma () || e .w .UInt32 (v )
}
func (w *Writer ) Int32 (v int32 ) (fail bool ) {
var val uint32
if v < 0 {
val = uint32 (-v )
fail = w .byte ('-' )
} else {
val = uint32 (v )
}
return fail || w .UInt32 (val )
}
func (e *Encoder ) Int32 (v int32 ) bool {
return e .comma () || e .w .Int32 (v )
}
func (w *Writer ) UInt64 (v uint64 ) (fail bool ) {
q0 := v
q1 := q0 / 1000
if q1 == 0 {
fail = fail || writeFirstBuf (w , digits [q0 ])
return fail
}
r1 := q0 - q1 *1000
q2 := q1 / 1000
if q2 == 0 {
fail = fail || writeFirstBuf (w , digits [q1 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
r2 := q1 - q2 *1000
q3 := q2 / 1000
if q3 == 0 {
fail = fail || writeFirstBuf (w , digits [q2 ])
fail = fail || writeBuf (w , digits [r2 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
r3 := q2 - q3 *1000
q4 := q3 / 1000
if q4 == 0 {
fail = fail || writeFirstBuf (w , digits [q3 ])
fail = fail || writeBuf (w , digits [r3 ])
fail = fail || writeBuf (w , digits [r2 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
r4 := q3 - q4 *1000
q5 := q4 / 1000
if q5 == 0 {
fail = fail || writeFirstBuf (w , digits [q4 ])
fail = fail || writeBuf (w , digits [r4 ])
fail = fail || writeBuf (w , digits [r3 ])
fail = fail || writeBuf (w , digits [r2 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
r5 := q4 - q5 *1000
q6 := q5 / 1000
if q6 == 0 {
fail = fail || writeFirstBuf (w , digits [q5 ])
fail = fail || writeBuf (w , digits [r5 ])
fail = fail || writeBuf (w , digits [r4 ])
fail = fail || writeBuf (w , digits [r3 ])
fail = fail || writeBuf (w , digits [r2 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
r6 := q5 - q6 *1000
fail = fail || writeFirstBuf (w , digits [q6 ])
fail = fail || writeBuf (w , digits [r6 ])
fail = fail || writeBuf (w , digits [r5 ])
fail = fail || writeBuf (w , digits [r4 ])
fail = fail || writeBuf (w , digits [r3 ])
fail = fail || writeBuf (w , digits [r2 ])
fail = fail || writeBuf (w , digits [r1 ])
return fail
}
func (e *Encoder ) UInt64 (v uint64 ) bool {
return e .comma () || e .w .UInt64 (v )
}
func (w *Writer ) Int64 (v int64 ) (fail bool ) {
var val uint64
if v < 0 {
val = uint64 (-v )
fail = w .byte ('-' )
} else {
val = uint64 (v )
}
return fail || w .UInt64 (val )
}
func (e *Encoder ) Int64 (v int64 ) bool {
return e .comma () || e .w .Int64 (v )
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .