Skip to content

Commit 4619e90

Browse files
committed
Use rstrip for chomp
Performance is than the regex in most cases. If a large portion of the end of the string is newlines then a regex could be more performant.
1 parent d8bbc91 commit 4619e90

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/BlockScalars.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ function block(str::AbstractString, block_scalar::AbstractString="")
3131
end
3232

3333
if chomp == 'c'
34-
str = replace(str, r"\n+$" => "\n")
34+
str = rstrip(str, '\n') * '\n'
3535
elseif chomp == 's'
36-
str = replace(str, r"\n+$" => "")
36+
str = rstrip(str, '\n')
3737
elseif chomp != 'k'
3838
throw(ArgumentError("Unknown block chomping indicator: $(repr(chomp))"))
3939
end

0 commit comments

Comments
 (0)