Skip to content

Commit

Permalink
Revert the strpbrk optimization
Browse files Browse the repository at this point in the history
because it's much slower on M1 #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.
  • Loading branch information
k0kubun committed Nov 5, 2022
1 parent 12058c3 commit 30691c8
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions ext/erb/erb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 30691c8

Please sign in to comment.