Skip to content

Commit 180ea9f

Browse files
authored
perf(colour): replace Sprintf/ParseUint round-trip in NewColour with direct bit arithmetic (#1274)
1 parent 68a08b0 commit 180ea9f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

colour.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type Colour int32
5252

5353
// NewColour creates a Colour directly from RGB values.
5454
func NewColour(r, g, b uint8) Colour {
55-
return ParseColour(fmt.Sprintf("%02x%02x%02x", r, g, b))
55+
return Colour(int32(r)<<16|int32(g)<<8|int32(b)) + 1
5656
}
5757

5858
// Distance between this colour and another.

0 commit comments

Comments
 (0)