Lets reduce string comparisons here.

This commit is contained in:
Alexander Andreev 2022-06-27 03:03:22 +04:00
parent 149675cd86
commit f2d7271111
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -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)