commit 5bee2f7: [Minor] Skip useless abs as we use squares

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Jul 8 08:21:09 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-08 09:19:55 +0100
URL: https://github.com/rspamd/rspamd/commit/5bee2f7fbd9274a3b23211218bbd26d098ecdddd (HEAD -> master)

[Minor] Skip useless abs as we use squares
Suggested by: trave11er

---
 src/libserver/html/html_block.hxx | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/libserver/html/html_block.hxx b/src/libserver/html/html_block.hxx
index 122d35aa3..76b41c14c 100644
--- a/src/libserver/html/html_block.hxx
+++ b/src/libserver/html/html_block.hxx
@@ -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;


More information about the Commits mailing list