Commit Graph

8 Commits

Author SHA1 Message Date
Takashi Kokubun 9af344a421 [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
2022-11-05 08:34:32 +00:00
Takashi Kokubun 458d6fb15e [ruby/erb] Optimize away the rb_convert_type call using RB_TYPE_P
https://github.com/ruby/erb/commit/12058c3784
2022-11-05 07:52:46 +00:00
Takashi Kokubun e8873e01b6 [ruby/erb] Use strpbrk only when str is long enough for SIMD
This is the same trick used by https://github.com/k0kubun/hescape to
choose the best strategy for different scenarios.

https://github.com/ruby/erb/commit/af26da2858
2022-11-05 07:52:45 +00:00
Takashi Kokubun 419d2fc14d [ruby/erb] Optimize the no-escape case with strpbrk
(https://github.com/ruby/erb/pull/29)

Typically, strpbrk(3) is optimized pretty well with SIMD instructions.
Just using it makes this as fast as a SIMD-based implementation for the
no-escape case.

Not utilizing this for escaped cases because memory allocation would be
a more significant bottleneck for many strings anyway. Also, there'll be
some overhead in calling a C function (strpbrk) many times because we're
not using SIMD instructions directly. So using strpbrk all the time
might not necessarily be faster.
2022-11-05 06:58:48 +00:00
Takashi Kokubun b169d78c88 [ruby/erb] Avoid using prepend + super for fallback
(https://github.com/ruby/erb/pull/28)

`prepend` is prioritized more than ActiveSupport's monkey-patch, but the
monkey-patch needs to work.

https://github.com/ruby/erb/commit/611de5a865
2022-11-04 16:46:29 +00:00
Takashi Kokubun ccf32a5ca4 [ruby/erb] Do not allocate a new String if not needed
[Feature #19102]https://github.com/ruby/erb/commit/ecebf8075c
2022-11-04 07:07:24 +00:00
Takashi Kokubun 20efeaddbe [ruby/erb] Optimize away to_s if it's already T_STRING
[Feature #19102]https://github.com/ruby/erb/commit/38c6e182fb
2022-11-04 07:07:24 +00:00
Takashi Kokubun dc5d06e9b1 [ruby/erb] Copy CGI.escapeHTML to ERB::Util.html_escape
https://github.com/ruby/erb/commit/ac9b219fa9
2022-11-04 07:07:23 +00:00