Merge: Less char boxings
authorJean Privat <jean@pryen.org>
Wed, 27 Aug 2014 15:11:16 +0000 (11:11 -0400)
committerJean Privat <jean@pryen.org>
Wed, 27 Aug 2014 15:11:16 +0000 (11:11 -0400)
commitda25554d40444ce4984d37f4564042900cdeea8f
tree4f81e2122e41438b35c43adfa8b0e029742f7b2d
parent6cc4c5c2c4df26b828e9e7ecbcf0484e5c7c5e63
parentc6558c425a99eae927a3db2d0665c2b0f7c7a843
Merge: Less char boxings

Because of the way the boxing is done in nitg-s, the services in the `Text::chars` view cause unnecessary boxing of chars.

After profiling, we found that the biggest consumers of such boxing are `Lexer::get_token` and `BufferedIStream::read_all`.

Thus, the idea is to implement a efficient `Text::[]` method that do not use the `chars` view. Then to update the two consumers to use it instead.

With `nitg nitg.nit`, the total gain is approx 5%, and the number of boxes of char is reduced by 70% (from 4.8Mboxes to 1.4Mboxes).

Note: this is only an easy workaround until the boxing is done better in nitg (mid-term goal)

Pull-Request: #688
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
lib/standard/string.nit