BufPool for Identifier

This commit is contained in:
Patrick O'brien 2016-08-13 23:30:53 +10:00
parent d2862ef281
commit e4800f9af8
2 changed files with 5 additions and 4 deletions
strmangle

View file

@ -78,17 +78,18 @@ func Identifier(in int) string {
n = 1 + int(math.Log(float64(in))/math.Log(float64(ln)))
}
cols := make([]byte, n)
cols := GetBuffer()
defer PutBuffer(cols)
for i := 0; i < n; i++ {
divisor := int(math.Pow(float64(ln), float64(n-i-1)))
rem := in / divisor
cols[i] = idAlphabet[rem]
cols.WriteByte(idAlphabet[rem])
in -= rem * divisor
}
return string(cols)
return cols.String()
}
// Plural converts singular words to plural words (eg: person to people)