mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Freezing couple of more string '0' & '.' and using the string appending to do the same string manipulation. This was we avoid the duplicate strings with freeze and append modifies existing string
This commit is contained in:
parent
0db9c83a60
commit
9c30e1b167
1 changed files with 4 additions and 2 deletions
|
@ -29,9 +29,11 @@ module ActiveSupport
|
|||
|
||||
formatted_string =
|
||||
if BigDecimal === rounded_number && rounded_number.finite?
|
||||
s = rounded_number.to_s('F') + '0'*precision
|
||||
s = rounded_number.to_s('F')
|
||||
s << '0'.freeze * precision
|
||||
a, b = s.split('.'.freeze, 2)
|
||||
a + '.' + b[0, precision]
|
||||
a << '.'.freeze
|
||||
a << b[0, precision]
|
||||
else
|
||||
"%00.#{precision}f" % rounded_number
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue