Skip to content

[Repo Assist] perf: word-at-a-time copy in l_strcat and l_strncat#127

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-strcat-strncat-2026-04-13-3b38cd54f6a1f4d7
Draft

[Repo Assist] perf: word-at-a-time copy in l_strcat and l_strncat#127
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-strcat-strncat-2026-04-13-3b38cd54f6a1f4d7

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Summary

l_strcat and l_strncat had inefficient byte-at-a-time loops that are now replaced with word-at-a-time equivalents.

Changes

  • l_strcat: Now delegates to l_strcpy(dst + l_strlen(dst), src), which uses the word-at-a-time path when both pointers are word-aligned — matching the optimisation already present in l_strcpy.
  • l_strncat: The byte-at-a-time while (*dst) dst++ scan is replaced with dst + l_strlen(dst), giving O(n/W) instead of O(n) for long destination strings.

Rationale

l_strcpy already has a word-at-a-time implementation. Reusing it in l_strcat is a correctness-free win: no behaviour change, just faster hot paths for long strings.

Test Status

✅ Linux gcc+clang: all assertions passed
⚠️ ARM/AArch64/RISC-V/Windows/WASI: not tested locally — CI will cover these

Generated by 🌈 Repo Assist at {run-started}. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@1f672aef974f4246124860fc532f82fe8a93a57e

l_strcat: replace byte-at-a-time loop with l_strcpy() which uses
word-at-a-time writes when both pointers are word-aligned. This
removes the redundant byte loop while keeping the fast l_strlen()
end-of-dst scan.

l_strncat: replace byte-at-a-time dst scan (while *dst) with
l_strlen() which uses the word-at-a-time technique, giving O(n/W)
instead of O(n) for long destination strings.

No behaviour change; all tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants