commit 156701a: [Project] Css: Simplify debug code
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Feb 10 19:56:06 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-02-10 14:49:37 +0000
URL: https://github.com/rspamd/rspamd/commit/156701a114419ecc5393464dc744c47e97ae623c
[Project] Css: Simplify debug code
---
src/libserver/css/css_tokeniser.cxx | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx
index bce13eeae..6094f9e68 100644
--- a/src/libserver/css/css_tokeniser.cxx
+++ b/src/libserver/css/css_tokeniser.cxx
@@ -816,18 +816,19 @@ auto css_parser_token::debug_token_str() -> std::string
const auto *token_type_str = get_token_type();
std::string ret = token_type_str;
- if (std::holds_alternative<std::string_view>(value)) {
- ret += "; value=";
- ret += std::get<std::string_view>(value);
- }
- else if (std::holds_alternative<double>(value)) {
- ret += "; value=";
- ret += std::to_string(std::get<double>(value));
- }
- else if (std::holds_alternative<char>(value)) {
- ret += "; value=";
- ret += std::get<char>(value);
- }
+ std::visit([&](auto arg) -> auto {
+ using T = std::decay_t<decltype(arg)>;
+
+ if constexpr (std::is_same_v<T, std::string_view>) {
+ ret += "; value=";
+ ret += arg;
+ }
+ else if constexpr (std::is_same_v<T, double> || std::is_same_v<T, char>) {
+ ret += "; value=";
+ ret += std::to_string(arg);
+ }
+ },
+ value);
if ((flags & (~number_dimension)) != default_flags) {
ret += "; flags=" + std::to_string(flags);
More information about the Commits
mailing list