Skip to content

ChafaPalette: Inline palette search helpers - #335

Merged
hpjansson merged 1 commit into
hpjansson:masterfrom
leonardcser:pr-palette-inline
Jun 9, 2026
Merged

ChafaPalette: Inline palette search helpers#335
hpjansson merged 1 commit into
hpjansson:masterfrom
leonardcser:pr-palette-inline

Conversation

@leonardcser

Copy link
Copy Markdown
Contributor

update_candidates and update_candidates_with_color_index_diff are called once per palette entry inside tight loops in pick_color_fixed_* functions. GCC does not inline them automatically at -O2, adding call/return overhead in a very hot path.

Mark both functions static inline. This is a pure compiler hint with no functional change.

Performance

Linux x86_64, AMD Ryzen 9 7900X, GCC 15.2 -O2, perf stat -r 3

Workload Baseline Optimized Delta
sixel 512x384 diffusion 256c 1323.8 ms 1203.9 ms -9%
sixel 512x384 diffusion 16c 1043.7 ms 893.2 ms -14%

@hpjansson hpjansson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but by convention the commit message should read ChafaPalette: ....

@leonardcser leonardcser changed the title chafa: Inline palette search helpers ChafaPalette: Inline palette search helpers Jun 9, 2026
@leonardcser
leonardcser requested a review from hpjansson June 9, 2026 18:28
@hpjansson
hpjansson merged commit 5979b99 into hpjansson:master Jun 9, 2026
1 check passed
@hpjansson

Copy link
Copy Markdown
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants