commit 293b687: [Minor] Use float
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Jul 8 09:07:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-07-08 10:03:56 +0100
URL: https://github.com/rspamd/rspamd/commit/293b68749ccbe72a8d122e8a8ac4d87ad9757076 (HEAD -> master)
[Minor] Use float
---
src/libserver/html/html_block.hxx | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/libserver/html/html_block.hxx b/src/libserver/html/html_block.hxx
index 76b41c14c..64b53ed7c 100644
--- a/src/libserver/html/html_block.hxx
+++ b/src/libserver/html/html_block.hxx
@@ -185,20 +185,21 @@ struct html_block {
}
auto is_similar_colors = [](const rspamd::css::css_color &fg, const rspamd::css::css_color &bg) -> bool {
+ constexpr const auto min_visible_diff = 0.1f;
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;
+ auto ravg = (fg.r + bg.r) / 2.0f;
/* Square diffs */
diff_r *= diff_r;
diff_g *= diff_g;
diff_b *= diff_b;
- auto diff = std::sqrt(2.0 * diff_r + 4.0 * diff_g + 3.0 * diff_b +
- (ravg * (diff_r - diff_b) / 256.0)) / 256.0;
+ auto diff = std::sqrt(2.0f * diff_r + 4.0f * diff_g + 3.0f * diff_b +
+ (ravg * (diff_r - diff_b) / 256.0f)) / 256.0f;
- return diff < 0.1;
+ return diff < min_visible_diff;
};
/* Check if we have both bg/fg colors */
if ((mask & (bg_color_mask|fg_color_mask)) == (bg_color_mask|fg_color_mask)) {
More information about the Commits
mailing list