ircd::json: Optimize json::type() ABI.
ircd::json: Fix indentation; minor cleanup.
This commit is contained in:
parent
55a73624d2
commit
c77df219b5
|
@ -105,28 +105,28 @@ template<>
|
|||
inline ircd::json::stack::array &
|
||||
ircd::json::stack::stack::top<ircd::json::stack::array>(stack &s)
|
||||
{
|
||||
return array::top(s);
|
||||
return array::top(s);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline const ircd::json::stack::array &
|
||||
ircd::json::stack::stack::top<ircd::json::stack::array>(const stack &s)
|
||||
{
|
||||
return array::top(s);
|
||||
return array::top(s);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline ircd::json::stack::object &
|
||||
ircd::json::stack::stack::top<ircd::json::stack::object>(stack &s)
|
||||
{
|
||||
return object::top(s);
|
||||
return object::top(s);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline const ircd::json::stack::object &
|
||||
ircd::json::stack::stack::top<ircd::json::stack::object>(const stack &s)
|
||||
{
|
||||
return object::top(s);
|
||||
return object::top(s);
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
@ -29,26 +29,18 @@ namespace ircd::json
|
|||
/// not use the strict overload.
|
||||
IRCD_OVERLOAD(strict)
|
||||
|
||||
// Determine the type
|
||||
enum type type(const string_view &);
|
||||
enum type type(const string_view &, std::nothrow_t);
|
||||
enum type type(const string_view &, strict_t);
|
||||
enum type type(const string_view &, strict_t, std::nothrow_t);
|
||||
|
||||
// Query if type
|
||||
bool type(const string_view &, const enum type &, strict_t);
|
||||
bool type(const string_view &, const enum type &);
|
||||
|
||||
// Utils
|
||||
string_view reflect(const enum type &);
|
||||
[[gnu::pure]] string_view reflect(const enum type) noexcept;
|
||||
|
||||
extern const string_view literal_null;
|
||||
extern const string_view literal_true;
|
||||
extern const string_view literal_false;
|
||||
extern const string_view empty_string;
|
||||
extern const string_view empty_object;
|
||||
extern const string_view empty_array;
|
||||
extern const int64_t undefined_number;
|
||||
// Determine the type w/ strict correctness (full scan)
|
||||
[[gnu::pure]] bool type(const string_view &, const enum type, strict_t) noexcept;
|
||||
[[gnu::pure]] enum type type(const string_view &, strict_t, std::nothrow_t) noexcept;
|
||||
enum type type(const string_view &, strict_t);
|
||||
|
||||
// Determine the type quickly
|
||||
[[gnu::pure]] bool type(const string_view &, const enum type) noexcept;
|
||||
[[gnu::pure]] enum type type(const string_view &, std::nothrow_t) noexcept;
|
||||
enum type type(const string_view &);
|
||||
}
|
||||
|
||||
enum ircd::json::type
|
||||
|
|
|
@ -36,7 +36,15 @@ namespace ircd::json
|
|||
void valid(const string_view &);
|
||||
std::string why(const string_view &);
|
||||
|
||||
struct stats extern stats;
|
||||
extern const string_view literal_null;
|
||||
extern const string_view literal_true;
|
||||
extern const string_view literal_false;
|
||||
extern const string_view empty_string;
|
||||
extern const string_view empty_object;
|
||||
extern const string_view empty_array;
|
||||
extern const int64_t undefined_number;
|
||||
|
||||
extern struct stats stats;
|
||||
}
|
||||
|
||||
/// Statistics counter access; unfortunately these cannot participate as
|
||||
|
|
17
ircd/json.cc
17
ircd/json.cc
|
@ -4754,7 +4754,8 @@ namespace ircd::json::parser
|
|||
|
||||
bool
|
||||
ircd::json::type(const string_view &buf,
|
||||
const enum type &type)
|
||||
const enum type type)
|
||||
noexcept
|
||||
{
|
||||
const bool ret
|
||||
{
|
||||
|
@ -4780,6 +4781,7 @@ ircd::json::type(const string_view &buf)
|
|||
enum ircd::json::type
|
||||
ircd::json::type(const string_view &buf,
|
||||
std::nothrow_t)
|
||||
noexcept
|
||||
{
|
||||
enum type ret;
|
||||
if(!parser::parse(begin(buf), end(buf), parser::type_parse, ret))
|
||||
|
@ -4842,8 +4844,9 @@ namespace ircd::json::parser
|
|||
|
||||
bool
|
||||
ircd::json::type(const string_view &buf,
|
||||
const enum type &type,
|
||||
const enum type type,
|
||||
strict_t)
|
||||
noexcept
|
||||
{
|
||||
const bool ret
|
||||
{
|
||||
|
@ -4871,6 +4874,7 @@ enum ircd::json::type
|
|||
ircd::json::type(const string_view &buf,
|
||||
strict_t,
|
||||
std::nothrow_t)
|
||||
noexcept
|
||||
{
|
||||
enum type ret;
|
||||
if(!parser::parse(begin(buf), end(buf), parser::type_parse_strict, ret))
|
||||
|
@ -4880,7 +4884,8 @@ ircd::json::type(const string_view &buf,
|
|||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::json::reflect(const enum type &type)
|
||||
ircd::json::reflect(const enum type type)
|
||||
noexcept
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
|
@ -4891,8 +4896,6 @@ ircd::json::reflect(const enum type &type)
|
|||
case STRING: return "STRING";
|
||||
}
|
||||
|
||||
throw type_error
|
||||
{
|
||||
"Unknown type %x", uint(type)
|
||||
};
|
||||
assert(false);
|
||||
return "STRING";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue