-
Notifications
You must be signed in to change notification settings - Fork 793
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
ljust and rjust are slow #3445
Comments
Please run more than one times your benchmark very similar |
Also, these functions with an empty padding parameter will stay in an infinite loop. |
dabroz
added a commit
to dabroz/mruby
that referenced
this issue
Feb 10, 2017
- String#ljust and String#rjust are now C functions to improve performance - infinite loop because of an empty padding argument is now prevented (ArgumentError is raised) - extra tests for ljust/rjust added
matz
added a commit
that referenced
this issue
Feb 10, 2017
String#ljust and String#rjust reimplementation (fix #3445)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The implementations of
String#ljust
andString#rjust
are slow (i.e. O(n^2) running time) when MRuby is built withMRB_UTF8_STRING
. This is because they repeatedly callString#size
, which callsutf8_strlen
, which must iterate over the whole string.This issue was reported by https://hackerone.com/ssarong
The text was updated successfully, but these errors were encountered: