1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Speed up integer casting from DB

We don't have the check the range when the value is coming from the DB,
so override type_cast_from_database to short-circuit the extra work.
The difference is huge but the absolute gain is quite small. That being
said this is a hotspot and it showed up on the radar when benchmarking
discourse.
This commit is contained in:
Sean Griffin 2014-11-18 13:40:03 -08:00
parent 1b9e85dbbd
commit 52fddcc653

View file

@ -14,6 +14,11 @@ module ActiveRecord
alias type_cast_for_database type_cast alias type_cast_for_database type_cast
def type_cast_from_database(value)
return if value.nil?
value.to_i
end
protected protected
attr_reader :range attr_reader :range