os97673/regexp_m17n — pull request #40 by svyatov (2014-08-04 15:41:22+00:00)
Title: Proper solution with dummy encodings "support" and performance optimizations

Based on my previous PR: https://github.com/os97673/regexp_m17n/pull/28

So skipping dummy encodings in tests is OK and we can't just `'string'.encode('UTF-7')` in code. **But!** We can `'string'.force_encoding('UTF-7')` and then pass that string to our `non_empty?` method and everything will blow up. That's why we need to properly handle those cases.

And to handle dummy encodings correctly we have 2 choices, basically.

1. Use external converter, e.g. `iconv`. Great choice for MRI, not so great for JRuby and others. I thinks it's quite rare encodings to work with, so supporting different external converters for each ruby and each ruby version will be real pain for nothing.
2. Tell developer about that problem by raising an error with meaningful message.

Here I went with a second one, because it's simple, fast, and solid multi-ruby solution.

Next to performance. As I stated here: https://github.com/os97673/regexp_m17n/pull/28#issuecomment-50963875 - memoizing of regular expression and using that memoization through checking regex and string encodings compatibility we are gaining ~50% in performance.

That's it. The most universal and the fastest solution at the moment with dummy encodings handling.