From ec0471934a8212af3ffd784eb63797ca669d1fc5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 18 May 2020 20:35:02 -0700 Subject: [PATCH] ircd::json: Minor simplifications. ircd::rfc3986: Minor simplifications. ircd::fmt: Minor cleanup. --- ircd/fmt.cc | 81 ++++++++++++++++++++++++++++++++----------------- ircd/json.cc | 57 +++++++++++++++++----------------- ircd/rfc3986.cc | 15 ++++++--- 3 files changed, 94 insertions(+), 59 deletions(-) diff --git a/ircd/fmt.cc b/ircd/fmt.cc index ebc88b8d9..ed615eb9a 100644 --- a/ircd/fmt.cc +++ b/ircd/fmt.cc @@ -549,10 +549,13 @@ const using karma::eps; using karma::maxwidth; - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Not a pointer"); - }); + throw illegal + { + "Not a pointer" + }; + }}; struct generator :karma::grammar @@ -619,10 +622,13 @@ const using karma::eps; using karma::maxwidth; - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Not a printable character"); - }); + throw illegal + { + "Not a printable character" + }; + }}; struct generator :karma::grammar @@ -658,10 +664,13 @@ const using karma::eps; using karma::maxwidth; - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Failed to print signed value"); - }); + throw illegal + { + "Failed to print signed value" + }; + }}; const auto closure([&](const bool &boolean) { @@ -696,10 +705,13 @@ ircd::fmt::signed_specifier::operator()(char *&out, const arg &val) const { - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Failed to print signed value"); - }); + throw illegal + { + "Failed to print signed value" + }; + }}; const auto closure([&out, &max, &spec, &val] (const long &integer) @@ -768,10 +780,13 @@ ircd::fmt::unsigned_specifier::operator()(char *&out, const arg &val) const { - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Failed to print unsigned value"); - }); + throw illegal + { + "Failed to print unsigned value" + }; + }}; const auto closure([&out, &max, &spec, &val] (const ulong &integer) @@ -840,10 +855,13 @@ ircd::fmt::hex_lowercase_specifier::operator()(char *&out, const arg &val) const { - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Failed to print hexadecimal value"); - }); + throw illegal + { + "Failed to print hexadecimal value" + }; + }}; const auto closure([&](const ulong &integer) { @@ -911,10 +929,13 @@ ircd::fmt::hex_uppercase_specifier::operator()(char *&out, const arg &val) const { - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Failed to print hexadecimal value"); - }); + throw illegal + { + "Failed to print hexadecimal value" + }; + }}; const auto closure([&](const ulong &integer) { @@ -984,10 +1005,13 @@ ircd::fmt::float_specifier::operator()(char *&out, const arg &val) const { - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Failed to print floating point value"); - }); + throw illegal + { + "Failed to print floating point value" + }; + }}; thread_local uint _precision_; _precision_ = s.precision; @@ -1045,10 +1069,13 @@ const using karma::maxwidth; using karma::unused_type; - static const auto throw_illegal([] + static const auto throw_illegal{[] { - throw illegal("Not a printable string"); - }); + throw illegal + { + "Not a printable string" + }; + }}; struct generator :karma::grammar diff --git a/ircd/json.cc b/ircd/json.cc index 962c9e66f..0ee2a4634 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -2258,11 +2258,11 @@ const namespace ircd::json { - using vector_rule = parser::rule; - - [[gnu::visibility("internal")]] extern const vector_rule vector_object; - [[gnu::visibility("internal")]] extern const vector_rule vector_next_parse; - [[gnu::visibility("internal")]] extern const vector_rule vector_begin_parse; + [[gnu::visibility("internal")]] + extern const parser::rule + vector_object, + vector_next_parse, + vector_begin_parse; } decltype(ircd::json::vector_object) @@ -2421,13 +2421,13 @@ catch(const qi::expectation_failure &e) namespace ircd::json { - using object_rule = parser::rule; - - [[gnu::visibility("internal")]] extern const object_rule object_member; - [[gnu::visibility("internal")]] extern const object_rule object_next; - [[gnu::visibility("internal")]] extern const object_rule object_begin; - [[gnu::visibility("internal")]] extern const object_rule object_next_parse; - [[gnu::visibility("internal")]] extern const object_rule object_begin_parse; + [[gnu::visibility("internal")]] + extern const parser::rule + object_member, + object_next, + object_begin, + object_next_parse, + object_begin_parse; } decltype(ircd::json::object::max_recursion_depth) @@ -2792,13 +2792,13 @@ ircd::json::sorted(const object::member *const &begin, namespace ircd::json { - using array_rule = parser::rule; - - [[gnu::visibility("internal")]] extern const array_rule array_value; - [[gnu::visibility("internal")]] extern const array_rule array_next; - [[gnu::visibility("internal")]] extern const array_rule array_begin; - [[gnu::visibility("internal")]] extern const array_rule array_next_parse; - [[gnu::visibility("internal")]] extern const array_rule array_begin_parse; + [[gnu::visibility("internal")]] + extern const parser::rule + array_value, + array_next, + array_begin, + array_next_parse, + array_begin_parse; } decltype(ircd::json::array::max_recursion_depth) @@ -3981,8 +3981,10 @@ ircd::json::operator==(const value &a, const value &b) namespace ircd::json { - [[gnu::visibility("internal")]] extern const parser::rule<> validation; - [[gnu::visibility("internal")]] extern const parser::rule<> validation_expect; + [[gnu::visibility("internal")]] + extern const parser::rule<> + validation, + validation_expect; } decltype(ircd::json::validation) @@ -3997,12 +3999,13 @@ ircd::json::validation_expect expect[validation] }; -const ircd::string_view ircd::json::literal_null { "null" }; -const ircd::string_view ircd::json::literal_true { "true" }; -const ircd::string_view ircd::json::literal_false { "false" }; -const ircd::string_view ircd::json::empty_string { "\"\"" }; -const ircd::string_view ircd::json::empty_object { "{}" }; -const ircd::string_view ircd::json::empty_array { "[]" }; +const ircd::string_view +ircd::json::literal_null { "null" }, +ircd::json::literal_true { "true" }, +ircd::json::literal_false { "false" }, +ircd::json::empty_string { "\"\"" }, +ircd::json::empty_object { "{}" }, +ircd::json::empty_array { "[]" }; decltype(ircd::json::undefined_number) ircd::json::undefined_number diff --git a/ircd/rfc3986.cc b/ircd/rfc3986.cc index 09265e7d4..2820d0cad 100644 --- a/ircd/rfc3986.cc +++ b/ircd/rfc3986.cc @@ -621,11 +621,16 @@ ircd::rfc3986::encode(const mutable_buffer &buf, namespace ircd::rfc3986 { - [[gnu::visibility("internal")]] extern const parser::rule host_literal; - [[gnu::visibility("internal")]] extern const parser::rule host_non_literal; - [[gnu::visibility("internal")]] extern const parser::rule host_alternative; - [[gnu::visibility("internal")]] extern const parser::rule host_parse; - [[gnu::visibility("internal")]] extern const parser::rule port_parse; + [[gnu::visibility("internal")]] + extern const parser::rule + host_literal, + host_non_literal, + host_alternative, + host_parse; + + [[gnu::visibility("internal")]] + extern const parser::rule + port_parse; } decltype(ircd::rfc3986::host_literal)