]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Skip useless abs as we use squares
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 8 Jul 2021 08:19:55 +0000 (09:19 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 8 Jul 2021 08:19:55 +0000 (09:19 +0100)
Suggested by: trave11er

src/libserver/html/html_block.hxx

index 122d35aa323025a76b7e47b04fd364e26ece9b63..76b41c14cf502408e93b8f3fd77930de9978aff2 100644 (file)
@@ -185,11 +185,12 @@ struct html_block {
                }
 
                auto is_similar_colors = [](const rspamd::css::css_color &fg, const rspamd::css::css_color &bg) -> bool {
-                       auto diff_r = std::abs(fg.r - bg.r);
-                       auto diff_g = std::abs(fg.g - bg.g);
-                       auto diff_b = std::abs(fg.b - bg.b);
+                       auto diff_r = ((float)fg.r - bg.r);
+                       auto diff_g = ((float)fg.g - bg.g);
+                       auto diff_b = ((float)fg.b - bg.b);
                        auto ravg = (fg.r + bg.r) / 2.0;
 
+                       /* Square diffs */
                        diff_r *= diff_r;
                        diff_g *= diff_g;
                        diff_b *= diff_b;