The implementations of String#ljust and String#rjust are slow (i.e. O(n^2) running time) when MRuby is built with MRB_UTF8_STRING. This is because they repeatedly call String#size, which calls utf8_strlen, which must iterate over the whole string.
$ echo '"".ljust(100000)' | time bin/mruby
57.46 real 57.01 user 0.21 sys
$ echo '"".rjust(100000)' | time bin/mruby
57.17 real 56.90 user 0.14 sys
- 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