-
-
Notifications
You must be signed in to change notification settings - Fork 144
Optimize map #1033
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
Optimize map #1033
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #1033 +/- ##
==========================================
- Coverage 93.77% 93.74% -0.03%
==========================================
Files 129 129
Lines 5012 4988 -24
Branches 327 327
==========================================
- Hits 4700 4676 -24
Misses 249 249
Partials 63 63 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #1033 will not alter performanceComparing Summary
|
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.
Pull Request Overview
This PR streamlines map rendering by replacing dynamic palettes with compile-time constants, refactors data parsing loops for performance, and optimizes change detection in map pieces.
- Replaced
Lazy<Vec<u8>>palettes withconstslices and fixed-size transparency arrays - Switched byte-order reads to
from_le_bytesand simplified iteration closures toforloops - Updated
update_pointsto early-exit on unchanged data and adjusted tests for slice inputs
| // Newer bots will return a different pixel index per room | ||
| // mapping all to the floor color | ||
| let pixel = if *pixel_idx > *MAP_IMAGE_PALETTE_LEN as u8 { | ||
| let pixel = if pixel_idx > MAP_IMAGE_PALETTE_LEN { |
Copilot
AI
Jun 20, 2025
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.
The check pixel_idx > MAP_IMAGE_PALETTE_LEN allows pixel_idx == MAP_IMAGE_PALETTE_LEN to slip through, leading to an out-of-bounds palette index. Change the condition to >= to correctly treat indices equal to the palette length as floor.
| let pixel = if pixel_idx > MAP_IMAGE_PALETTE_LEN { | |
| let pixel = if pixel_idx >= MAP_IMAGE_PALETTE_LEN { |
| } | ||
| }); | ||
|
|
||
| let mut points = Vec::with_capacity(subset.coordinates.len() / 2); |
Copilot
AI
Jun 20, 2025
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.
[nitpick] Pre-allocating based on the string length may over-allocate. Consider using numbers.size_hint() or collecting into a temporary Vec<f32> first to get an accurate capacity estimate.
| let mut points = Vec::with_capacity(subset.coordinates.len() / 2); | |
| let mut points = Vec::with_capacity(numbers.size_hint().0 / 2); |
No description provided.