Skip to content

Commit 6d8efed

Browse files
committed
optimised replace_all by using intrinsic character slicing
1 parent ef2e35c commit 6d8efed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/stdlib_strings.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ pure function replace_all_char_char_char(string, pattern, replacement) result(re
630630
if (string(s_i:s_i) == pattern(p_i:p_i)) then
631631
if (p_i == length_pattern) then
632632
res = res // &
633-
& slice(string, first=last, last=s_i - length_pattern, stride=1) // &
633+
& string(last : s_i - length_pattern) // &
634634
& replacement
635635
last = s_i + 1
636636
p_i = 0
@@ -645,7 +645,7 @@ pure function replace_all_char_char_char(string, pattern, replacement) result(re
645645
end do
646646
end if
647647

648-
res = res // slice(string, first=last)
648+
res = res // string(last : length_string)
649649

650650
end function replace_all_char_char_char
651651

0 commit comments

Comments
 (0)