Skip to content

Linear time list operations#5

Closed
haampie wants to merge 11 commits into
masterfrom
hs/fix/speed
Closed

Linear time list operations#5
haampie wants to merge 11 commits into
masterfrom
hs/fix/speed

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented May 13, 2026

Avoids string concatenation overhead in extend and preextend

"tricks" used:

  • Use set -- and "$*" with different IFS for fast concatenation (when prefix is empty)
  • Eliminate the array reversal in preextend
  • Build a local temporary string instead of extending a big string one item at a time (quadratic time)

Results in a 60% runtime reduction for the included benchmark.

haampie and others added 8 commits May 13, 2026 13:40
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Avoids quadratic string concatenation overhead in extend and preextend
by processing incoming lists into local strings and appending them to
the target list in a single operation.

Signed-off-by: Harmen Stoppels <harmenstoppels@gmail.com>
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
haampie added 3 commits May 14, 2026 11:50
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Signed-off-by: Harmen Stoppels <me@harmenstoppels.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant