ruby-changes:74366
From: Takashi <ko1@a...>
Date: Sat, 5 Nov 2022 17:34:54 +0900 (JST)
Subject: [ruby-changes:74366] 9af344a421 (master): [ruby/erb] Revert the strpbrk optimization
https://git.ruby-lang.org/ruby.git/commit/?id=9af344a421 From 9af344a42129ea193d6dba92d62458c5f3429507 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Sat, 5 Nov 2022 01:30:41 -0700 Subject: [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 --- ext/erb/erb.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ext/erb/erb.c b/ext/erb/erb.c index a103fb30e4..b72c295a81 100644 --- a/ext/erb/erb.c +++ b/ext/erb/erb.c @@ -38,11 +38,6 @@ escaped_length(VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/erb/erb.c#L38 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); -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/