mirror of
https://github.com/nlohmann/json.git
synced 2026-10-23 22:38:55 +00:00
2.5.7: force-inline detail::parse_array_index (#5891)
Moving parse_array_index out of json_pointer stopped clang from inlining it into the pointer resolution (JsonPointerAt/citm_catalog +17%, JsonPointerAt/twitter +8%); JSON_HEDLEY_ALWAYS_INLINE restores the baseline. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 file changed
+3
-1
@@ -70,9 +70,11 @@ enum class array_index_status
|
|||||||
@note this function never throws; json_pointer::array_index(), the callers that
|
@note this function never throws; json_pointer::array_index(), the callers that
|
||||||
must not throw, and the json_view pointer resolution build on it instead
|
must not throw, and the json_view pointer resolution build on it instead
|
||||||
of each re-implementing the RFC 6901 digit rules and the range check
|
of each re-implementing the RFC 6901 digit rules and the range check
|
||||||
|
@note force-inlined: as a free function template it is no longer inlined into
|
||||||
|
the pointer resolution, which makes JsonPointerAt up to 17% slower (#5891)
|
||||||
*/
|
*/
|
||||||
template<typename SizeType, typename StringType>
|
template<typename SizeType, typename StringType>
|
||||||
array_index_status parse_array_index(const StringType& s, SizeType& idx) noexcept
|
JSON_HEDLEY_ALWAYS_INLINE array_index_status parse_array_index(const StringType& s, SizeType& idx) noexcept
|
||||||
{
|
{
|
||||||
// error condition (cf. RFC 6901, Sect. 4)
|
// error condition (cf. RFC 6901, Sect. 4)
|
||||||
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0'))
|
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0'))
|
||||||
|
|||||||
Reference in new issue
Block a user