-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
fix: Replace custom repeatString
function with repeat()
#2820
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
Looks like the old function was there because at the time |
I didn't perform any benchmark, but I would assume that the built-in functionality should be at least as fast as the custom implementation. Actually I would expect it to be faster as a lot of the string allocation+concatenation can be done in one go in the native implementation. Update: Did a benchmark now out of curiosity. Result: It depends 😅 If you count the cost of creating the function it the old version is always slower than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
Should be same-or-faster unless we're repeating really small strings, in which case the implementation shouldn't matter anyway. But it's nice to use the built-in language feature. Do all marked-supported language runtimes now support |
repeatString
function with repeat()
repeatString
function with repeat()
We don't have a list of supported runtimes outside of Node.js as far I know. We support Node.js 18 and newer since Marked 5.0.0 (see #2767) |
Marked version:
5.0.3
Description
While working on #2805 I noticed that there are a few
repeatString
functions that could trivially be replaced withString.proptotype.repeat()
, which is already used in some other places in the code anyway.Contributor
Committer
In most cases, this should be a different person than the contributor.