]> source.dussan.org Git - rspamd.git/commitdiff
[Project] Use string_view to constexpr variant unpacking
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 18 Jan 2021 20:19:51 +0000 (20:19 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 22 Jan 2021 15:58:05 +0000 (15:58 +0000)
src/libserver/css/css_selector.hxx
src/libserver/css/css_value.hxx

index 273ff603ecff44a2af15ab738f701b39a3b89143..4c12b3b4159ab2a2fb2ce72017afd7301bc4f5c4 100644 (file)
@@ -47,9 +47,9 @@ struct css_selector {
                return std::nullopt;
        }
 
-       std::optional<const std::string> to_string (void) const {
+       constexpr std::optional<const std::string_view> to_string (void) const {
                if (type == selector_type::SELECTOR_ELEMENT) {
-                       return std::get<std::string>(value);
+                       return std::string_view(std::get<std::string>(value));
                }
                return std::nullopt;
        }
index e750d775e52e16927be085eb15699c2afbce6e06..fca0e043357de68405646aadd219121a2485c578 100644 (file)
@@ -95,9 +95,9 @@ struct css_value {
                return std::nullopt;
        }
 
-       std::optional<const std::string> to_string (void) const {
+       constexpr std::optional<std::string_view> to_string (void) const {
                if (type == css_value_type::CSS_VALUE_STRING) {
-                       return std::get<std::string>(value);
+                       return std::string_view(std::get<std::string>(value));
                }
 
                return std::nullopt;