Conversation
…e state This makes it possible to common out the implementations of functions that should be available to both kinds. Also, moves a bit of code that could easily live in the `RoomEventCacheState` impl block, instead of being free functions.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6314 +/- ##
==========================================
- Coverage 89.83% 89.81% -0.03%
==========================================
Files 376 376
Lines 102469 102455 -14
Branches 102469 102455 -14
==========================================
- Hits 92058 92017 -41
- Misses 6840 6856 +16
- Partials 3571 3582 +11 ☔ View full report in Codecov by Sentry. |
Merging this PR will improve performance by 98.51%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | Restore session [memory store] |
222.4 ms | 112.1 ms | +98.51% |
Comparing bnjbvr/refactor-event-cache-lock-guards (4fd97b4) with main (81bed18)
Hywan
left a comment
There was a problem hiding this comment.
Looks sensible to me. Left a comment about the Deref (extended to DerefMut) implementations, not a blocker.
| &self.state | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Since state is pub, is it really useful to have a Deref implementation here? My fear is that it can create a bit of confusion when reading the code (despite being simpler in appearance).
There was a problem hiding this comment.
"jump to definition" and every other actions seem to work fine with Deref/DerefMut. Not having the Deref impl would mean that every current caller of state_guard.room_linked_chunk() would need to be replaced with state_guard.state.room_linked_chunk().
As a thought experiment, I've tried to remove the Deref impls, and I get around 40 compilation errors, which shows that the Deref is then used in multiple places. Since Deref is rather idiomatic in Rust, especially expected for a lock guard (the stdlib has such a Deref impl for its own lock guards), and there are many uses of this, with the related refactors, I'll keep it for now. We can definitely revisit this later, if needs be.
This makes it possible to common out the implementations of functions that should be available to both kinds.
Also, moves a bit of code that could easily live in the
RoomEventCacheStateimpl block, instead of being free functions.Only code motion, no changes in functionality.
CHANGELOG.mdfiles.