Skip to content

Reduce use of pointer arithmetic in TinyPtrSet and BitVector #47334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2025

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented Jun 28, 2025

@cdumez cdumez self-assigned this Jun 28, 2025
@cdumez cdumez marked this pull request as ready for review June 28, 2025 20:42
@cdumez cdumez requested review from darinadler, ddkilzer and rniwa June 28, 2025 20:42
Comment on lines +473 to +474
std::span<const uint8_t> byteSpan() const LIFETIME_BOUND { return unsafeMakeSpan(reinterpret_cast<const uint8_t*>(m_words), byteCount(numBits())); }
std::span<uint8_t> byteSpan() LIFETIME_BOUND { return unsafeMakeSpan(reinterpret_cast<uint8_t*>(m_words), byteCount(numBits())); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code used bit casts and this uses reinterpret casts. Is there a reason to choose one over the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code I removed was using bit_cast whereas the code I'm updating was using reinterpret_cast and still is. I did not purposely change the way of casting. I can probably use std::bit_cast here since we're casting to bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually using std::bit_cast doesn't build here.

@cdumez cdumez added the merge-queue Applied to send a pull request to merge-queue label Jun 28, 2025
https://bugs.webkit.org/show_bug.cgi?id=295141

Reviewed by Darin Adler.

Reduce use of pointer arithmetic in TinyPtrSet and BitVector by leveraging
flexible array members instead.

* Source/WTF/wtf/BitVector.h:
* Source/WTF/wtf/TinyPtrSet.h:
(WTF::TinyPtrSet::OutOfLineList::list):

Canonical link: https://commits.webkit.org/296776@main
@webkit-commit-queue
Copy link
Collaborator

Committed 296776@main (fbcfad4): https://commits.webkit.org/296776@main

Reviewed commits have been landed. Closing PR #47334 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit fbcfad4 into WebKit:main Jun 28, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants