MCPcopy Index your code
hub / github.com/aceld/zinx / itoa

Function itoa

zlog/logger_core.go:433–454  ·  view source on GitHub ↗

Convert an integer to a fixed-length string, where the width of the string should be greater than 0 Ensure that the buffer has sufficient capacity (将一个整形转换成一个固定长度的字符串,字符串宽度应该是大于0的 要确保buffer是有容量空间的)

(buf *bytes.Buffer, i int, wID int)

Source from the content-addressed store, hash-verified

431// (将一个整形转换成一个固定长度的字符串,字符串宽度应该是大于0的
432// 要确保buffer是有容量空间的)
433func itoa(buf *bytes.Buffer, i int, wID int) {
434 var u uint = uint(i)
435 if u == 0 && wID <= 1 {
436 buf.WriteByte('0')
437 return
438 }
439
440 // Assemble decimal in reverse order.
441 var b [32]byte
442 bp := len(b)
443 for ; u > 0 || wID > 0; u /= 10 {
444 bp--
445 wID--
446 b[bp] = byte(u%10) + '0'
447 }
448
449 // avoID slicing b to avoID an allocation.
450 for bp < len(b) {
451 buf.WriteByte(b[bp])
452 bp++
453 }
454}

Callers 1

formatHeaderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected