From 2ef1fb2c455ca53a0c1e1768f50824926ce28bd3 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 10 Jul 2013 16:32:04 +0900 Subject: 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) --- activesupport/lib/active_support/core_ext/string/access.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') 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 -- cgit v1.2.3