Skip to content

[Repo Assist] perf: bulk memcpy/memset for %s padding and string copy in l_vsnprintf#137

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-vsnprintf-bulk-str-2026-04-19-e43284a-f36a8cb10d0889a3
Draft

[Repo Assist] perf: bulk memcpy/memset for %s padding and string copy in l_vsnprintf#137
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-vsnprintf-bulk-str-2026-04-19-e43284a-f36a8cb10d0889a3

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Summary

Replace character-by-character loops in l_vsnprintf's %s path with bulk l_memcpy/l_memset calls, giving O(n/word_size) throughput instead of O(n) for padded string printing.

Root Cause

The %s format specifier's padding and copy loops used L_SNPRINTF_EMIT one character at a time, creating per-character overhead for potentially large strings.

Fix

Replace with bounds-safe bulk operations using a L_SNPRINTF_AVAIL() helper macro that prevents size_t underflow when n==0. Truncation and NUL termination semantics are preserved.

Test Status

✅ Linux/gcc: build PASS, 1515 assertions PASS
✅ Linux/clang: build PASS, 1513 assertions PASS
✅ Verify: 52 binaries, max 117KB, static PASS

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

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