Commit 981ee02c7c ("Fix performance problem with /k/i and /s/i") was
merged for Ruby 4.0 to enable partial Boyer-Moore optimization for
patterns containing 's' or 'k' by using the prefix before those
characters.
However, when 's' or 'k' appears at the start of a pattern (no usable
prefix), set_bm_skip() returns 0 and the code returned early without
setting any optimization mode, leaving reg->optimize at
ONIG_OPTIMIZE_NONE. This caused up to 30x slowdown for patterns like
/slackware/i when matched against strings with non-ASCII characters.
This patch keeps the improvement from 981ee02c7c for patterns with
3+ char prefix, while fixing the regression by falling back to
ONIG_OPTIMIZE_EXACT_IC with the full pattern when the usable prefix
is less than 3 characters.
Before: /\bslackware\b/i with non-ASCII string: 2.24 us/op
After: /\bslackware\b/i with non-ASCII string: 0.70 us/op (3.2x faster)
[Bug #21824]
When onig_reg_init() returns an error, onig_free_body() which is called
via onig_new() may crash because some members are not properly
initialized. Fix it.
https://github.com/k-takata/Onigmo/commit/d2a090a57e
* Multiplication result may overflow 'int' before it is converted to
'OnigDistance'.
* Comparison is always true because code <= 122.
* This statement makes ExprStmt unreachable.
* Empty block without comment
387ad616c3
This reverts commit 282338f88a8bf0807a7a1d21b06f78abe9de8fac.
It seems that the commit didn't improve the performance.
Revert it to fixk-takata/Onigmo#100.
cef834cb3a
E.g.
For the pattern `/----k/i`, optimization was totally turned off.
Make it possible to use the characters before `k` (i.e. `----`) for
optimization.
9c13de8d06
According to the C99 specification section 7.20.3.2 paragraph 2:
> If ptr is a null pointer, no action occurs.
So we do not need to check that the pointer is a null pointer.
* regcomp.c (print_indent_tree): make a function for debug static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* regcomp.c (get_min_match_length): Fix compile error with old version
of fcc (Fujitsu C Compiler) on Solaris 10. [Bug #13059][ruby-dev:49909]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* meta character \X matches Unicode 9.0.0 characters with some workarounds
for UTR #51 Unicode Emoji, Version 4.0 emoji zwj sequences.
[Feature #12831] [ruby-core:77586]
The term "character" can have many meanings bytes, codepoints, combined
characters, and so on. "grapheme cluster" is highest one of such words,
which means user-perceived characters.
Unicode Standard Annex #29 UNICODE TEXT SEGMENTATION specifies how to
handle grapheme clusters (extended grapheme cluster).
But some specs aren't updated to current situation because Unicode Emoji
is rapidly extended without well definition.
It breaks the precondition of UTR#29 "Grapheme cluster boundaries can be
easily tested by looking at immediately adjacent characters". (the
sentence will be removed in the next version)
Though some of its detail are described in Unicode Technical Report #51
UNICODE EMOJI but it is not merged into UTR#29 yet.
http://unicode.org/reports/tr29/http://unicode.org/reports/tr51/http://unicode.org/Public/emoji/4.0/
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Ruby's Regexp doesn't allow normal numbered groups if the regexp
has named groups. On such case it optimizes out related NT_ENCLOSE.
But even on the case it can use \g<0>.
This fix not to remove NT_ENCLOSE whose regnum is 0.
[ruby-core:75828] [Bug #12454]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[bug] fix problem with optimization of \z (Issue #16) [Bug #8210]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e