cgi
cgi copied to clipboard
escape_html: Avoid buffer allocation for strings with no escapable character
This is a port of the change I submitted in https://github.com/ruby/erb/pull/87.
- Perform buffer allocation on first instance of escapable character.
- Instead of copying characters one at a time, copy unescaped segments using
memcpy.
Note: the cgi implementation differs from the erb implementation in that it always creates a new string (using rb_str_dup), even for strings without any escapable characters, while the erb implementation will return the input string unchanged.
Thanks. I will look test failure of mingw platform. It may be caused with https://github.com/ruby/setup-ruby/issues/818