mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 11:25:24 +00:00
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:
parent
374ab82dd6
commit
56a573ab4b
@ -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
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user