aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/number_helper
diff options
context:
space:
mode:
authorAnkit Gupta <ankit.gupta8898@gmail.com>2016-04-10 16:51:45 -0700
committerAnkit Gupta <ankit.gupta8898@gmail.com>2016-04-10 16:51:45 -0700
commit0db9c83a604b19e764293d0cb8cfe4b982497278 (patch)
tree219c9ce4509528081dcd47f066f9b825f53038bf /activesupport/lib/active_support/number_helper
parentb8d1dbf9933e3d67e15cd06116164286ba15c6a7 (diff)
downloadrails-0db9c83a604b19e764293d0cb8cfe4b982497278.tar.gz
rails-0db9c83a604b19e764293d0cb8cfe4b982497278.tar.bz2
rails-0db9c83a604b19e764293d0cb8cfe4b982497278.zip
Freezing the dots as they are causing extra string initialization on every iteration of calling the helper. Eases on some memory bloat
Diffstat (limited to 'activesupport/lib/active_support/number_helper')
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb2
-rw-r--r--activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb b/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb
index 45ae8f1a93..43c5540b6f 100644
--- a/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb
@@ -12,7 +12,7 @@ module ActiveSupport
private
def parts
- left, right = number.to_s.split('.')
+ left, right = number.to_s.split('.'.freeze)
left.gsub!(delimiter_pattern) do |digit_to_delimit|
"#{digit_to_delimit}#{options[:delimiter]}"
end
diff --git a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb
index 981c562551..21e4fd672f 100644
--- a/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb
+++ b/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb
@@ -30,7 +30,7 @@ module ActiveSupport
formatted_string =
if BigDecimal === rounded_number && rounded_number.finite?
s = rounded_number.to_s('F') + '0'*precision
- a, b = s.split('.', 2)
+ a, b = s.split('.'.freeze, 2)
a + '.' + b[0, precision]
else
"%00.#{precision}f" % rounded_number