-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only get draw_target-width when we actually draw #683
base: main
Are you sure you want to change the base?
Conversation
src/state.rs
Outdated
|
||
let mut draw_state = drawable.state(); | ||
// First check whether there is something to be drawn. | ||
if self.draw_target.drawable(force_draw, now).is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This double call to drawable
is sort of ugly in my eyes.
However, the returned drawable
prevents us from calling self.draw_target.width()
, since the mutable borrow is still active.
@djc Tests pass locally now. |
Actually, this is not working, since |
Should (hopefully) work now. The contrast in speed is actually bigger when using |
@djc Let me know if you need any else for this PR. |
When calling
BarState::draw
, there is a call toself.draw_target.width()
.However, that operation can be expensive and the width is not needed, if there is no draw-target.
Thus, this PR delays the calling
.width()
if there is not target to draw to.For comparison, I've used this minibenchmark:
Using the latest release it runs in about 400ms, whilst the fixed version uses about 100ms.
The issue surfaced with uv, when resolving many packages: astral-sh/uv#10384