bitly/nsq — pull request #505 by iand (2014-11-24 10:44:02+00:00)
Title: util: speed up failure path of ByteToBase10

ready for review

The failure path for ByteToBase10 was not breaking out of the loop so the entire byte slice would still be scanned even if the first byte gave an error. Additonally a failure would allocate to create a new error.

Benchmark before:
'''
BenchmarkByteToBase10Valid	100000000	20.8 ns/op	0 B/op	0 allocs/op
BenchmarkByteToBase10Invalid	20000000	81.3 ns/op	16 B/op	1 allocs/op
```

Bechmark after:

```
BenchmarkByteToBase10Valid	100000000	14.8 ns/op	0 B/op	0 allocs/op
BenchmarkByteToBase10Invalid	300000000	4.68 ns/op	0 B/op	0 allocs/op
```