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

fastStartsWith is no longer faster than the native String.prototype.startsWith #4517

Open
SukkaW opened this issue Dec 11, 2024 · 4 comments · May be fixed by #4518
Open

fastStartsWith is no longer faster than the native String.prototype.startsWith #4517

SukkaW opened this issue Dec 11, 2024 · 4 comments · May be fixed by #4518

Comments

@SukkaW
Copy link

SukkaW commented Dec 11, 2024

export function fastStartsWith(haystack: string, needle: string): boolean {

Benchmark.

On both modern Chrome and modern Firefox, fastStartsWith is always consistently slower.

I can help create a PR migrate from the fastStartsWith with the native startsWith.

@seia-soto
Copy link
Member

For me, String.prototype.startsWith is about 2 times faster. Nice finding, can I ask you to prepare a PR? Or I can make it then include you as a co-author.

@SukkaW
Copy link
Author

SukkaW commented Dec 11, 2024

Nice finding, can I ask you to prepare a PR

Sure, I am going to create a PR~

@SukkaW
Copy link
Author

SukkaW commented Dec 11, 2024

fastStartsWithFrom is also consistently slower than String.prototype.startsWith, Benchmark. I will migrate them as well.

@SukkaW SukkaW linked a pull request Dec 11, 2024 that will close this issue
@SukkaW
Copy link
Author

SukkaW commented Dec 11, 2024

cc @seia-soto #4518

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 a pull request may close this issue.

2 participants