Skip to content

Optimize CubicBezierShape::find_cross_t - #8413

Open
oscargus wants to merge 1 commit into
emilk:mainfrom
oscargus:bezieropt
Open

Optimize CubicBezierShape::find_cross_t#8413
oscargus wants to merge 1 commit into
emilk:mainfrom
oscargus:bezieropt

Conversation

@oscargus

@oscargus oscargus commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
  • I have followed the instructions in the PR template

Factor out common constants to reduce the number of multiplications. During checking the results (comparing my hand-optimized code with the previous version using AI), the AI pointed out that d is always 0, so I removed that as well.

It is possible to rewrite the equations a bit further, like:
let p = (a / c - h * h);
but not sure that it will be beneficial (on superscalar machines) due to introduced data dependencies.

I also have a doubt what will happen when p = 0. I think it may have to be special cased as p = 0 => r = 0 => division by zero (before taking acos).

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Preview available at https://egui-pr-preview.github.io/pr/8413-bezieropt
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

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.

1 participant