csv-diff-report
csv-diff-report copied to clipboard
minimal requirement to use CGI.escapeHTML
We need to require only cgi/escape to use CGI.escapeHTML.
This change save memory usage about 265 KB and load time about ten milliseconds.
require "objspace"
GC.start
before = ObjectSpace.memsize_of_all
require "cgi"
after = ObjectSpace.memsize_of_all
puts "about %d KB" % ((after - before).fdiv(1024).round)
# => 269 KB
require "objspace"
GC.start
before = ObjectSpace.memsize_of_all
require "cgi/escape"
after = ObjectSpace.memsize_of_all
puts "about %d KB" % ((after - before).fdiv(1024).round)
# => 4 KB
(Ruby 2.7.0)
Thanks for the PR, but unfortunately, this change does not work for older versions of Ruby, which are still a target for this project.
How about this? cgi/escape was introduced at Ruby 2.3.0. cgi/utils is available instead of cgi/escape for older Ruby versions (even for Ruby 1.9).
cgi/utils is larger than cgi/escape, but is smaller than entire cgi.