Backported the optimization of compiling charsets in regular expressions
(issue #19329).  This is needed to apply the patch from issue #17381.
Issue #17381: Fixed ranges handling in case-insensitive regular expressions.