Skip to content

Commit 17b047d

Browse files
committed
improved append operator's performance
1 parent 32e8b8e commit 17b047d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/stdlib_stringlist_type.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ function append_char( lhs, rhs )
222222
character(len=*), intent(in) :: rhs
223223
type(stringlist_type) :: append_char
224224

225-
append_char = lhs // string_type( rhs )
225+
append_char = lhs ! Intent: creating a full, deep copy
226+
call append_char%insert_at( list_tail, rhs )
226227

227228
end function append_char
228229

@@ -245,7 +246,8 @@ function prepend_char( lhs, rhs )
245246
type(stringlist_type), intent(in) :: rhs
246247
type(stringlist_type) :: prepend_char
247248

248-
prepend_char = string_type( lhs ) // rhs
249+
prepend_char = rhs ! Intent: creating a full, deep copy
250+
call prepend_char%insert_at( list_head, lhs )
249251

250252
end function prepend_char
251253

0 commit comments

Comments
 (0)