fix: return after peer color cache hit - #1640
Conversation
Color(peerSeed:isDark:) checked the cache but never returned on a hit, so every call recomputed the hue/saturation/brightness math and overwrote the cache entry with an identical value. The cache never actually short-circuited anything.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16e0a3d090
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import SwiftUI | ||
| @testable import bitchat | ||
|
|
||
| struct ColorPeerTests { |
There was a problem hiding this comment.
Serialize tests using the shared color counter
Because this Swift Testing suite is not marked serialized, its @Test methods can run concurrently under the repo's swift test --parallel CI path, but they all assert deltas against the same process-global Color._peerColorComputeCountForTesting. If differentAppearanceForSameSeedIsNotCachedTogether increments the counter between this test's reads, afterSecond == afterFirst can fail even when the cache behavior is correct; make this suite/test serialized or avoid assertions based on a shared global counter.
Useful? React with 👍 / 👎.
peer color cache checked for a hit but never returned, so every call recomputed the color and rewrote the same cache entry. added a debug-only counter so a test can actually assert the cache short-circuits.