-
Notifications
You must be signed in to change notification settings - Fork 814
Description
Hi,
I've written an app that runs with mruby or cruby and I noticed that the frame rate was massively degraded when running with mruby. After investigation I narrowed it down to calls to String#codepoints which where happening multiple times per frame. Of course I can, and probably will improve my code to use a cache or eliminate it entirely but I think the method itself can be hugely optimized, after all the way its currently written works fine in cruby.
The implementation in https://github.com/mruby/mruby/blob/master/mrbgems/mruby-string-ext/mrblib/string.rb is:
self.split('').map{|x| x.ord}
I think this is made worse by the fact that the onig_regexp gem replaces String#split with its own version which probably adds a further performance penalty.
Presumably the GC is getting hammered. I guess doing it in C would be the best?
I'm not desperate for this but I thought I'd flag it.
Cheers!