Repository navigation
slist: avoid quadratic traversal when copying and exporting lists - #23361
Closed
cla7aye15I4nd wants to merge 9 commits into
Closed
cla7aye15I4nd wants to merge 9 commits into
cla7aye15I4nd wants to merge 9 commits into
Conversation
cla7aye15I4nd
marked this pull request as ready for review
October 11, 2026 08:05
There was a problem hiding this comment.
🟢 Approval recommended
The tail-pointer implementations preserve ownership, ordering, and allocation-failure cleanup semantics.
0 open findings
What changed in this PR
Optimizes internal slist construction from quadratic to linear time while preserving ordering and cleanup behavior.
Changes:
- Builds duplicated slists using a tracked tail pointer.
- Applies the same optimization to cookie-list exports.
| File | Description |
|---|---|
lib/slist.c |
Optimizes deep-copy list construction. |
lib/cookie.c |
Optimizes exported cookie-list construction. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bagder
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Curl_slist_duplicate() and cookie_list() append every new node by walking the output list from its head. Building n entries therefore does quadratic list traversal. Track the next link locally and append singleton nodes, making list construction linear while preserving deep copying, cookie iteration order and existing allocation-failure cleanup. The public curl_slist layout and append semantics are unchanged.
Validation:
Single-run CPU timings on macOS, Debug build (ms):
These are local performance measurements, not cross-platform guarantees. No new in-tree tests are added; the existing regressions and external checks above validate this traversal-only optimization.
AI-assisted implementation and local validation. Submitted for upstream review; cross-platform CI remains to be reviewed.
The macOS HTTP suite also exposed a DNS test-server shutdown race: a select timeout continued the event loop without checking got_exit_signal, so fixture teardown could hang. Check the signal at the loop condition. On macOS ARM64, an injected SIGTERM immediately before a select timeout reproduces the hang on the original server; the patched server exits and removes its PID file. A normal SIGTERM shutdown, the server build, checksrc and whitespace checks also pass.