From f2d72711111836d1cddd70ffb849c87e0d5a6311 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 27 Jun 2022 03:03:22 +0400 Subject: [PATCH] Lets reduce string comparisons here. --- internal/captcha/dwelling_captcha.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/captcha/dwelling_captcha.go b/internal/captcha/dwelling_captcha.go index 82110d5..a5eb7d0 100644 --- a/internal/captcha/dwelling_captcha.go +++ b/internal/captcha/dwelling_captcha.go @@ -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)