read the zlib dictionary length once in CopyDictionary - #63859
Conversation
|
Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at: https://dart-review.googlesource.com/c/sdk/+/526160 Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly. Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR). |
|
any update? |
|
CL has new comments, please view and respond to them in Gerrit. If a reviewer requested changes, push new commits to this PR and it will be automatically copied to Gerrit. After that you can mark reviewer comments as resolved in Gerrit and request another round of reviews. Note: when you add comments in Gerrit they only become visible after you send them by clicking Reply and Send. |
Introduce Filter::Dictionary, a std::unique_ptr<uint8_t[]> paired with the length that was actually copied, and pass it around by move instead of a raw pointer plus a separate length. CopyDictionary now drops the manual Dart_TypedDataAcquireData fast path and just uses Dart_ListGetAsBytes, which already handles typed data internally. Per review comments on the CL.
|
Pushed an update for both comments. The dictionary is now a Also dropped the hand-rolled |
|
https://dart-review.googlesource.com/c/sdk/+/526160 has been updated with the latest commits from this pull request. |
1 similar comment
|
https://dart-review.googlesource.com/c/sdk/+/526160 has been updated with the latest commits from this pull request. |
|
CL has new comments, please view and respond to them in Gerrit. If a reviewer requested changes, push new commits to this PR and it will be automatically copied to Gerrit. After that you can mark reviewer comments as resolved in Gerrit and request another round of reviews. Note: when you add comments in Gerrit they only become visible after you send them by clicking Reply and Send. |
CopyDictionaryinruntime/bin/filter.ccsizes the dictionary heap buffer from oneDart_ListLengthcall, andFilter_CreateZLibInflate/Filter_CreateZLibDeflatethen callDart_ListLengthon the same object a second time to get the length they hand to the filter. For a user-defined class implementingList<int>that call dispatches to the Dartlengthgetter, so the two reads can disagree, and a getter that returns a bigger value the second time leavesdictionary_length_pointing past the end of the allocation thatinflateSetDictionary/deflateSetDictionarylater read from.ZLibCodec,ZLibEncoderandZLibDecoderall pass the caller'sList<int>straight through to these natives, so no copy happens on the Dart side first.Having
CopyDictionaryreport the number of bytes it actually copied keeps the buffer and the length in sync and drops the second lookup at both call sites.Contribution guidelines:
dart format.Note that this repository uses Gerrit for code reviews. Your pull request will be automatically converted into a Gerrit CL and a link to the CL written into this PR. The review will happen on Gerrit but you can also push additional commits to this PR to update the code review.