Lets reduce string comparisons here.
This commit is contained in:
parent
149675cd86
commit
f2d7271111
@ -26,10 +26,11 @@ func NewDwellingCaptcha(expiry time.Duration) *DwellingCaptcha {
|
||||
}
|
||||
|
||||
func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
||||
isDark := style == "dark"
|
||||
ctx := gg.NewContext(dwImageWidth, dwImageHeight)
|
||||
|
||||
// fill background
|
||||
if style == "dark" {
|
||||
if isDark {
|
||||
ctx.SetRGB255(0x0a, 0x0a, 0x0a)
|
||||
} else {
|
||||
ctx.SetRGB255(0xf5, 0xf5, 0xf5)
|
||||
@ -37,7 +38,7 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
||||
ctx.Clear()
|
||||
|
||||
// draw text
|
||||
if style == "dark" {
|
||||
if isDark {
|
||||
ctx.SetRGB255(0xf5, 0xf5, 0xf5)
|
||||
} else {
|
||||
ctx.SetRGB255(0x0a, 0x0a, 0x0a)
|
||||
|
Loading…
Reference in New Issue
Block a user