mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 02:02:38 +01:00
ircd::json: Inline trivial array::empty(); label branch expect.
This commit is contained in:
parent
d104a8ea0d
commit
972502fd19
2 changed files with 14 additions and 14 deletions
|
@ -96,3 +96,16 @@ const
|
|||
{
|
||||
return { string_view::end(), string_view::end() };
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::json::array::empty()
|
||||
const
|
||||
{
|
||||
const string_view &sv{*this};
|
||||
// Allow empty objects '{}' to pass this assertion; this function is not
|
||||
// a type-check. Some serializers (like browser JS) might give an empty
|
||||
// object before it has any context that the set is an array; it doesn't
|
||||
// matter here for us.
|
||||
assert(sv.size() > 2 || sv.empty() || sv == empty_array || sv == empty_object);
|
||||
return sv.size() <= 2;
|
||||
}
|
||||
|
|
15
ircd/json.cc
15
ircd/json.cc
|
@ -3163,7 +3163,7 @@ ircd::json::array::at(const size_t &i)
|
|||
const
|
||||
{
|
||||
const auto it(find(i));
|
||||
if(it == end())
|
||||
if(unlikely(it == end()))
|
||||
throw not_found
|
||||
{
|
||||
"indice %zu", i
|
||||
|
@ -3195,19 +3195,6 @@ const
|
|||
return std::distance(begin(), end());
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::json::array::empty()
|
||||
const
|
||||
{
|
||||
const string_view &sv{*this};
|
||||
// Allow empty objects '{}' to pass this assertion; this function is not
|
||||
// a type-check. Some serializers (like browser JS) might give an empty
|
||||
// object before it has any context that the set is an array; it doesn't
|
||||
// matter here for us.
|
||||
assert(sv.size() > 2 || sv.empty() || sv == empty_array || sv == empty_object);
|
||||
return sv.size() <= 2;
|
||||
}
|
||||
|
||||
//
|
||||
// array::const_iterator
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue