More efficiently reset inspect implementation

Not that `inspect` is anywhere close to be a hostspot, but just
to not allow a less defficient pattern.

Instead of allocating an UnboundMethod and bind_call it, we can
directly replace the method.
This commit is contained in:
Jean Boussier 2024-01-30 08:34:22 +01:00
parent 329582353c
commit ad81c30859
2 changed files with 2 additions and 6 deletions

View File

@ -152,9 +152,7 @@ module ActiveRecord # :nodoc:
[self.class, cast_type, normalizer, normalize_nil?].hash
end
def inspect
Kernel.instance_method(:inspect).bind_call(self)
end
define_method(:inspect, Kernel.instance_method(:inspect))
private
def normalize(value)

View File

@ -30,9 +30,7 @@ module ActiveRecord
end
end
def inspect
Kernel.instance_method(:inspect).bind_call(self)
end
define_method(:inspect, Kernel.instance_method(:inspect))
def changed_in_place?(raw_old_value, value)
return false if value.nil?