Skip to content

made nanoprintf context static to reduce call overhead and size#709

Merged
adriweb merged 1 commit intomasterfrom
static_global_printf
Feb 27, 2026
Merged

made nanoprintf context static to reduce call overhead and size#709
adriweb merged 1 commit intomasterfrom
static_global_printf

Conversation

@ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Feb 24, 2026

Made npf_cnt_putc_ctx_t pc_cnt static in npf_vpprintf, moving them off of the stack frame. This changes frameset from 145 to 138. Call overhead was also reduced since NPF_PUTC(VAL) now calls a 1 argument function instead of a 2 argument function. Overall this saves 242 bytes with Clang 17 codegen.

This optimization can be controlled via the NANOPRINTF_STATIC_GLOBALS macro I have added

@adriweb adriweb merged commit e036b4c into master Feb 27, 2026
9 checks passed
@adriweb adriweb deleted the static_global_printf branch February 27, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants