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:
James Tucker
2022-11-09 20:49:30 -08:00
committed by GitHub
parent 0cd0786aef
commit 78a6b871fe
8 changed files with 21 additions and 12 deletions

View File

@@ -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)