Skip to content
Snippets Groups Projects

util_string: dynamically allocate and expand string lists

Merged Roland Wirth requested to merge rwirth/dynamic-string-lists into master

String lists grow dynamically, removing the need for preallocated arrays. This simplifies handling of large variable groups in the icon initialization phase.

The output lists of add_to_list are now ALLOCATABLE. They may be passed an unallocated argument, which is treated like an empty list and allocated using the new new_list subroutine. That subroutine initially allocates space for 8 strings. Every time the list needs to grow, the allocated size doubles. This ensures constant amortized runtime for adding to the list. No provisions are made for shrinking the list size, because they are usually short-lived.

The tests for add_to_list are adapted for the new interface, checking list expansion. A new test for new_list is added.

Edited by Yen-Chen Chen

Merge request reports

Merge request pipeline #67296 passed

Merge request pipeline passed for 7b7ad6a4

Test coverage 81.20% (-0.60%) from 1 job
Approval is optional
Ready to merge by members who can write to the target branch.

Merge details

  • 1 commit will be added to master.
  • Source branch will be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Some minor changes are required for the testing. Otherwise LGTM. Thanks for writing the unit tests.

  • Yen-Chen Chen requested review from @b382190

    requested review from @b382190

  • Roland Wirth added 1 commit

    added 1 commit

    • 7b7ad6a4 - test_util_string: fix test tags, cover untested line in add_to_list_1

    Compare with previous version

  • Yen-Chen Chen marked the checklist item Reviewed by a maintainer as completed

    marked the checklist item Reviewed by a maintainer as completed

  • Yen-Chen Chen marked the checklist item Incorporate review suggestions as completed

    marked the checklist item Incorporate review suggestions as completed

  • Yen-Chen Chen marked the checklist item Prior to merging, please remove any boilerplate from the MR description, retaining only the Please describe your feature in a couple of words and describe important implementation details of the feature section to maintain as completed

    marked the checklist item Prior to merging, please remove any boilerplate from the MR description, retaining only the Please describe your feature in a couple of words and describe important implementation details of the feature section to maintain as completed

  • Yen-Chen Chen marked the checklist item Remember to edit the commit message and select the proper changelog category (feature/bugfix/other) as completed

    marked the checklist item Remember to edit the commit message and select the proper changelog category (feature/bugfix/other) as completed

  • Yen-Chen Chen changed the description

    changed the description

  • Yen-Chen Chen approved this merge request

    approved this merge request

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading