[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
Draft
[Repo Assist] perf: word-at-a-time copy in l_strcat and l_strncat#127github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
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>
38 tasks
26 tasks
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.
🤖 This is an automated pull request from Repo Assist.
Summary
l_strcatandl_strncathad inefficient byte-at-a-time loops that are now replaced with word-at-a-time equivalents.Changes
l_strcat: Now delegates tol_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 inl_strcpy.l_strncat: The byte-at-a-timewhile (*dst) dst++scan is replaced withdst + l_strlen(dst), giving O(n/W) instead of O(n) for long destination strings.Rationale
l_strcpyalready has a word-at-a-time implementation. Reusing it inl_strcatis 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