elixir-lang/elixir — pull request #1902 by krestenkrab (2013-11-29 09:50:34+00:00)
Title: Reduce code size for unicode.ex

This changes the (macro) codegen for next_grapheme
so that the size of the resulting beam code is
significantly reduced. The main motivation is
to enable Erjang to compile this, as the JVM
has a 64k bytecode limit per function.

The code is changed so that a first the length
of the next grapheme is computed, and then it is
simply extracted. When the result of the complex
match operation is just a length, this causes
many of the branches in the new function
next_grapheme_length to ultimately collapse
because of CSE, thus effectively reducing the size
of `Elixir.String.Grapheme.beam` from 818k to 152k.