Skip to content

O(n) per-element eval loops in bulk array/publish operations instead of a single eval #285

Description

@codeforester

Summary

Several functions append array elements one at a time via a per-element eval call inside a loop, instead of building a local array once and publishing it with a single eval.

Details

  • lib/bash/list/lib_list.sh:57-64 (base_list_prepend), :80-89 (base_list_remove), :121-132 (base_list_unique)
  • lib/bash/arg/lib_arg.sh:259-262, :277-280 (base_arg_parse positional/repeatable publish)
  • base_list_append already does this correctly with one eval at lib_list.sh:39.

Impact

For large lists/positional counts, this multiplies parse/eval overhead needlessly compared to the single-eval pattern already used elsewhere in the same file.

Suggested fix

Accumulate into a local array first, then do one eval "$name=(\"\${local_array[@]}\")" per target, mirroring base_list_append's pattern.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type

Projects

Status
Triage

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions