Commit b1445d09 authored by rubic0n's avatar rubic0n

Remove 40KB of allocations (4,100 objects) from home feed

(When using dummy data)

* to_s(16) allocates a string per character
  Instead of converting the ord to hex and determining if the hex
  is over 2 characters long, just see if the ord is over 255.
* .match allocates a MatchData instance and sets all sorts of backrefs
  ($1, $2, etc). match? just returns a boolean.
parent 006322cf
......@@ -370,7 +370,7 @@ class Formatter
escaped = text.chars.map do |c|
output = begin
if c.ord.to_s(16).length > 2 && UNICODE_ESCAPE_BLACKLIST_RE.match(c).nil?
if c.ord > 255 && !UNICODE_ESCAPE_BLACKLIST_RE.match?(c)
CGI.escape(c)
else
c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment