Removed upb_Decoder's stateful, bespoke logic for field lookup. #21707
+48
−83
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.
Removed upb_Decoder's stateful, bespoke logic for field lookup.
upb_Decoder used to have its own logic for finding a MiniTable field by number. Instead of using the standard
upb_MiniTable_FindFieldByNumber()
function, it used a custom linear search that cached the most recently seen field index. The theory behind this design was that field numbers are usually serialized in increasing order, so by linear searching from the last seen index, we would have a small expected number of elements to inspect before finding the matching one.In practice, it appears that we can use the generic searching logic with no loss in performance. Removing the stateful search has several benefits:
last_field_index
). Note that it was not even possible to put this variable intoupb_Decoder
because it is preserved per parsed message, so we previously needed a stack oflast_field_index
values. This CL lets us get rid of that completely.