Skip to content
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

Use find8 and find16 in AdaptiveStringSearcher #28403

Conversation

Constellation
Copy link
Member

@Constellation Constellation commented May 10, 2024

@Constellation Constellation self-assigned this May 10, 2024
Copy link
Contributor

@Achierius Achierius left a comment

Choose a reason for hiding this comment

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

r=me

Comment on lines -89 to -95
// Special-case looking for the 0 char in other than one-byte strings.
// memchr mostly fails in this case due to every other byte being 0 in text
// that is mostly ascii characters.
for (int i = index; i < maxN; ++i) {
if (!subjectPtr[i])
return i;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this no longer apply? Or is it just not worth the upfront runtime?

Copy link
Member Author

Choose a reason for hiding this comment

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

This no longer applies since we use find16 instead of memchr.

Comment on lines +74 to +75
if constexpr (sizeof(PatternChar) == 2 && sizeof(SubjectChar) == 1) {
if (!isLatin1(patternFirstChar))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why could we handle this case before and not now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the previous one was using memchr and a hack for both 16 / 8 bit cases. Now the logic is completely different.

Copy link
Contributor

@ddegazio ddegazio left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

@MenloDorian MenloDorian left a comment

Choose a reason for hiding this comment

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

r=me

@Constellation Constellation added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 11, 2024
https://bugs.webkit.org/show_bug.cgi?id=274010
rdar://127894478

Reviewed by Mark Lam.

We should just use find8 and find16 in AdaptiveStringSearcher.
Since we have find16, we do not need to use memchr hack here.

* Source/WTF/wtf/text/AdaptiveStringSearcher.h:
(WTF::AdaptiveStringSearcherBase::findFirstCharacter):
(WTF::AdaptiveStringSearcherBase::alignDown): Deleted.
(WTF::AdaptiveStringSearcherBase::getHighestValueByte): Deleted.

Canonical link: https://commits.webkit.org/278644@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Use-find8-and-find16-in-AdaptiveStringSearcher branch from b8d9e6a to 31005e5 Compare May 11, 2024 01:51
@webkit-commit-queue
Copy link
Collaborator

Committed 278644@main (31005e5): https://commits.webkit.org/278644@main

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

@webkit-commit-queue webkit-commit-queue merged commit 31005e5 into WebKit:main May 11, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants