diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-01-08 11:20:56 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-01-08 11:27:43 +0100 |
commit | a03fed88f780922e3a3ab7b22af945f29a711ae4 (patch) | |
tree | 40773043da47196d92e5ac49cdaf0dda59b3ce02 /activesupport/lib | |
parent | 40a83d740fafddcb3cad3b2c2dbfa3c446338d12 (diff) | |
download | rails-a03fed88f780922e3a3ab7b22af945f29a711ae4.tar.gz rails-a03fed88f780922e3a3ab7b22af945f29a711ae4.tar.bz2 rails-a03fed88f780922e3a3ab7b22af945f29a711ae4.zip |
Revert "Speedup String#to"
This reverts commit 2ef1fb2c455ca53a0c1e1768f50824926ce28bd3.
As described in PR #13627 this commit broke functionality when passing
a negative Fixnum to the `String#to` method:
```ruby
assert_equal "hell", s.to(-2)
```
Before the revert, this failed with:
```
1) Failure:
StringAccessTest#test_#to_with_negative_Fixnum,_position_is_counted_from_the_end [test/core_ext/string_ext_test.rb:275]:
Expected: "hell"
Actual: nil
```
This revert is to keep the functionality on `master` working.
If there is another way to get the performance benefit and keep
the documented functionality we can add that.
/cc @amatsuda @carlosantoniodasilva
Diffstat (limited to 'activesupport/lib')
-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 d94e1bfca2..6018fd9641 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 + 1] + self[0..position] end # Returns the first character. If a limit is supplied, returns a substring |