Improve performance by avoiding regex construction (#20215)
```ruby 10.times { p /#{FOO}/.object_id } 10.times { p FOO_RE.object_id } ```
This commit is contained in:
parent
0cd0786aef
commit
78a6b871fe
8 changed files with 21 additions and 12 deletions
|
@ -8,7 +8,7 @@ class HashtagNormalizer
|
|||
private
|
||||
|
||||
def remove_invalid_characters(str)
|
||||
str.gsub(/[^[:alnum:]#{Tag::HASHTAG_SEPARATORS}]/, '')
|
||||
str.gsub(Tag::HASHTAG_INVALID_CHARS_RE, '')
|
||||
end
|
||||
|
||||
def ascii_folding(str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue