Explain optimization.

This commit is contained in:
jst 2015-03-18 19:56:53 +01:00
parent 962e93a6e5
commit d67851ed1f
1 changed files with 3 additions and 0 deletions

View File

@ -20,6 +20,9 @@ import "image"
// Keep value in [0,255] range.
func clampUint8(in int32) uint8 {
// casting a negative int to an uint will result in an overflown large int.
// this behavior will be exploited here and in other functions to archive
// a higher performance.
if uint32(in) < 256 {
return uint8(in)
}