[ruby/erb] Revert the strpbrk optimization

because it's much slower on M1 https://github.com/ruby/erb/pull/29.
It'd be too complicated to switch the implementation based on known
optimized platforms / versions.

Besides, short strings are the most common usages of this method and
SIMD doesn't really help that case. All in all, I can't justify the
existence of this code.

https://github.com/ruby/erb/commit/30691c8995
This commit is contained in:
Takashi Kokubun 2022-11-05 01:30:41 -07:00 committed by git
parent 458d6fb15e
commit 9af344a421
1 changed files with 0 additions and 5 deletions

View File

@ -38,11 +38,6 @@ escaped_length(VALUE str)
static VALUE
optimized_escape_html(VALUE str)
{
// Use strpbrk to optimize the no-escape case when str is long enough for SIMD.
if (RSTRING_LEN(str) >= 16 && strpbrk(RSTRING_PTR(str), "'&\"<>") == NULL) {
return str;
}
VALUE vbuf;
char *buf = ALLOCV_N(char, vbuf, escaped_length(str));
const char *cstr = RSTRING_PTR(str);