Skip to content

Commit 93d92d1

Browse files
author
José Valim
committed
Optimize rstrip for ascii chars
1 parent ce3674d commit 93d92d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/elixir/lib/string.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ defmodule String do
420420
# does not traverse the whole binary).
421421
def rstrip(string, char) when char in 0..127 do
422422
if :binary.last(string) == char do
423-
do_rstrip(string, "", char)
423+
rstrip(binary_part(string, 0, byte_size(string) - 1), char)
424424
else
425425
string
426426
end

0 commit comments

Comments
 (0)