slight menu optimization for long menus
What changed, and why it matters
This is a tiny performance tweak in the COLDCARD wallet's menu drawing code. It changes one loop bound so the device only redraws the visible menu items instead of also iterating over off-screen items. There is no security-relevant change visible in the diff.
No security action needed. Treat as a normal code-quality/performance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In shared/menu.py, the MenuSystem.redraw() loop bound changed from range(self.ypos+PER_M+1) to range(PER_M+1). The loop body computes real_idx = n+self.ypos, so the old code iterated from 0 to ypos+PER_M and then skipped items below ypos; the new code iterates exactly the PER_M+1 visible slots. This is a pure rendering optimization with no change to input handling, bounds checking, or data flow.
Changed components
shared/menu.py:MenuSystem.redraw()Inspect captured patch +1 / −1
diff --git a/shared/menu.py b/shared/menu.py
index ccaa9e5..c7ce83c 100644
--- a/shared/menu.py
+++ b/shared/menu.py
@@ -290,7 +290,7 @@ class MenuSystem:
dis.clear()
cursor_y = None
- for n in range(self.ypos+PER_M+1):
+ for n in range(PER_M+1):
real_idx = n+self.ypos
if real_idx >= self.count: break
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.