Fix compute_fov() O(n²) performance bug - return None instead of cell list #146
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#146
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Grid.compute_fov()has O(grid_size) performance instead of O(radius²) due to building a Python list of all visible cells by iterating through the entire grid.Benchmark on 1000×1000 grid:
compute_fov(): 15.76ms (iterates 1M cells)This is a 75x performance penalty from unnecessary list building.
Current Implementation (UIGrid.cpp:1192-1218)
Solution
Change
compute_fov()to returnNone. Users query visibility withis_in_fov(x, y).Implementation
py_compute_fov()Py_Noneinstead ofresult_listNotes
is_in_fov()per-cell as it draws