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.
Inline
_readPacked
manually and_withLimit
with a pragma to eliminateclosure allocation and calls in packed decoding loops.
_readPacked
is manually inlined as VM's inliner doesn't properly foldconstants after the inlinings, see
Closure and closure context field loads are not folded in AOT dart-lang/sdk#60068.
Introduce
PbList._addUnchecked
to add to the list without checking thevalue for validity and list for mutability.
When decoding a packed field, check the list mutability once, instead of for
every element.
When decoding a packed scalar field, don't check for value validity.
For scalar fields we need to make sure the field value is not null, which is
already guaranteed in the call sites as e.g.
input.readDouble
doesn'treturn nullable.
Sprinkle a bunch of
prefer-inline
s to make sure VM will inline one liners.Looking at the optimized flow graph, this should be quite fast compared to the
current version. However I can't benchmark this yet as none of the benchmarks
use packed fields.
I will update the benchmarks first, then revisit this PR.
TODO: I think "check" functions in
PbList
s can be completely eliminated for the scalars where we only check for nulls:protobuf.dart/protobuf/lib/src/protobuf/field_error.dart
Lines 75 to 107 in d00f905
The generated API for these have non-nullable element type (e.g.
PbList<int>
) so null checks no longer do anything (since null safety).