aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2013-07-10 16:32:04 +0900
committerAkira Matsuda <ronnie@dio.jp>2013-07-10 16:32:04 +0900
commit2ef1fb2c455ca53a0c1e1768f50824926ce28bd3 (patch)
treed1f8d723f7bece5cd584da0d4533642136ab00fa /activesupport/lib/active_support
parent956671831d43fa81a9f72e7fedbee3c4ef6e0896 (diff)
downloadrails-2ef1fb2c455ca53a0c1e1768f50824926ce28bd3.tar.gz
rails-2ef1fb2c455ca53a0c1e1768f50824926ce28bd3.tar.bz2
rails-2ef1fb2c455ca53a0c1e1768f50824926ce28bd3.zip
Speedup String#to
Benchmark: 1000000.times { str.to(30) } user system total real old 0.490000 0.110000 0.600000 ( 0.607374) new 0.390000 0.000000 0.390000 ( 0.387306)
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/string/access.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb
index 8fa8157d65..ee3b6d2b3f 100644
--- a/activesupport/lib/active_support/core_ext/string/access.rb
+++ b/activesupport/lib/active_support/core_ext/string/access.rb
@@ -59,7 +59,7 @@ class String
# str.from(0).to(-1) #=> "hello"
# str.from(1).to(-2) #=> "ell"
def to(position)
- self[0..position]
+ self[0, position + 1]
end
# Returns the first character. If a limit is supplied, returns a substring