avoid long pointer transversal

This commit is contained in:
Martin Diehl 2022-04-14 00:06:54 +02:00
parent 00671f943b
commit ca0df3389a
1 changed files with 6 additions and 7 deletions

View File

@ -119,7 +119,8 @@ module YAML_types
type, extends(tNode), public :: tList type, extends(tNode), public :: tList
class(tItem), pointer :: first => NULL() class(tItem), pointer :: first => NULL(), &
last => NULL()
contains contains
procedure :: asFormattedString => tList_asFormattedString procedure :: asFormattedString => tList_asFormattedString
@ -1350,13 +1351,11 @@ subroutine tList_append(self,node)
if (.not. associated(self%first)) then if (.not. associated(self%first)) then
allocate(item) allocate(item)
self%first => item self%first => item
self%last => item
else else
item => self%first allocate(self%last%next)
do while (associated(item%next)) item => self%last%next
item => item%next self%last => item
enddo
allocate(item%next)
item => item%next
end if end if
item%node => node item%node => node