You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor CacheEntry to avoid excessive RefCell overhead
Since the `RefCell::borrow{,_mut}()` methods both impose runtime
overhead each time they are called, we should avoid calling them
whenever possible. There are several things we can do to improve the
situation:
1. Since `Widgets::draw_widget()` already takes `&mut self`, we can
safely skip the runtime checks with `RefCell::get_mut()`. This
imposes zero overhead.
2. Since `Widgets::draw_widget()` already takes `&mut self`, we can take
a mutable reference to `CacheEntry::texture` directly. Since we don't
have any immutable public methods exposing the `texture` fields,
there's no need to wrap this in a `RefCell` at all.
The elimination of these two `RefCell` runtime checks performed during
the hot path in `Widgets::draw()` should hopefully improve performance
slightly.
0 commit comments