DEV: Remove String#match? and Regexp.match? polyfills (#12454)

This was added in Ruby 2.4. Discourse will no longer run on ruby versions older than that, so we can drop this polyfill
This commit is contained in:
David Taylor 2021-03-19 19:55:44 +00:00 committed by GitHub
parent 374ab82dd6
commit 56a573ab4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 21 deletions

View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
class String
# new to Ruby 2.4, fastest way of matching a string to a regex
unless method_defined? :match?
def match?(regex)
!!(self =~ regex)
end
end
end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
unless ::Regexp.instance_methods.include?(:match?)
class ::Regexp
# this is the fast way of checking a regex (zero string allocs) added in Ruby 2.4
# backfill it for now
def match?(string)
!!(string =~ self)
end
end
end