Skip to content

Commit 1584eeb

Browse files
committed
removed capacity function
1 parent 38052c2 commit 1584eeb

File tree

1 file changed

+13
-42
lines changed

1 file changed

+13
-42
lines changed

src/stdlib_stringlist.f90

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ module stdlib_stringlist
6161

6262
procedure, public :: len => length_list
6363

64-
procedure :: capacity => capacity_list
65-
6664
procedure :: to_future_at_idxn => convert_to_future_at_idxn
6765

6866
procedure, public :: to_current_idxn => convert_to_current_idxn
@@ -477,23 +475,6 @@ pure integer function length_list( list )
477475

478476
end function length_list
479477

480-
! capacity:
481-
482-
!> Version: experimental
483-
!>
484-
!> Returns the capacity of the list
485-
!> Returns an integer
486-
pure integer function capacity_list( list )
487-
!> Not a part of public API
488-
class(stringlist_type), intent(in) :: list
489-
490-
capacity_list = 0
491-
if ( allocated( list%stringarray ) ) then
492-
capacity_list = size( list%stringarray )
493-
end if
494-
495-
end function capacity_list
496-
497478
! to_future_at_idxn:
498479

499480
!> Version: experimental
@@ -614,29 +595,19 @@ subroutine insert_before_empty_positions( list, idxn, positions )
614595
old_len = list%len()
615596
new_len = old_len + positions
616597

617-
if ( list%capacity() < new_len ) then
618-
619-
allocate( new_stringarray(new_len) )
620-
621-
do i = 1, idxn - 1
622-
! TODO: can be improved by move
623-
new_stringarray(i) = list%stringarray(i)
624-
end do
625-
do i = idxn, old_len
626-
inew = i + positions
627-
! TODO: can be improved by move
628-
new_stringarray(inew) = list%stringarray(i)
629-
end do
630-
631-
call move_alloc( new_stringarray, list%stringarray )
632-
633-
else
634-
do i = old_len, idxn, -1
635-
inew = i + positions
636-
! TODO: can be improved by move
637-
list%stringarray(inew) = list%stringarray(i)
638-
end do
639-
end if
598+
allocate( new_stringarray(new_len) )
599+
600+
do i = 1, idxn - 1
601+
! TODO: can be improved by move
602+
new_stringarray(i) = list%stringarray(i)
603+
end do
604+
do i = idxn, old_len
605+
inew = i + positions
606+
! TODO: can be improved by move
607+
new_stringarray(inew) = list%stringarray(i)
608+
end do
609+
610+
call move_alloc( new_stringarray, list%stringarray )
640611

641612
list%size = new_len
642613

0 commit comments

Comments
 (0)