diff options
author | Akira Matsuda <ronnie@dio.jp> | 2013-07-10 16:32:04 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2013-07-10 16:32:04 +0900 |
commit | 2ef1fb2c455ca53a0c1e1768f50824926ce28bd3 (patch) | |
tree | d1f8d723f7bece5cd584da0d4533642136ab00fa /activesupport | |
parent | 956671831d43fa81a9f72e7fedbee3c4ef6e0896 (diff) | |
download | rails-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')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/access.rb | 2 |
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 |