common/json_parse_simple: make convenience functions inline #8414
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
json_tok_streq(…)
andjson_get_member(…)
are convenience wrappers forjson_tok_strneq(…)
andjson_get_membern(…)
respectively. Unfortunately, using them incurs a performance penalty in the common case where they are called with a string literal argument because the compiler is unable to substitute a compile-time constant in place of the buried call tostrlen(…)
.For example,
…will have worse performance than…
…because the former is forced to scan over
"example"
at run-time to count its length whereas the latter is able to elide thestrlen(…)
call at compile time.Hoist these convenience functions up into
common/json_parse_simple.h
and mark them asinline
so that the compiler can elide thestrlen(…)
call in the common case of calling these functions with a string literal argument.Checklist
Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked: