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:
parent
1b9e85dbbd
commit
52fddcc653
1 changed files with 5 additions and 0 deletions
|
@ -14,6 +14,11 @@ module ActiveRecord
|
|||
|
||||
alias type_cast_for_database type_cast
|
||||
|
||||
def type_cast_from_database(value)
|
||||
return if value.nil?
|
||||
value.to_i
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
attr_reader :range
|
||||
|
|
Loading…
Reference in a new issue