Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fewer submap inbounds checks by using _ib coords
Improve performance by removing inbounds-checks when we have already checked before that a point is inbound. This main intention of this commit is to remove the inbounds check from `map::get_nonant` by forcing the caller to supply an already-inbounds-checked tripoint using an `_ib` type. But in order to do that, two other changes are required (in this commit): 1. Change submap coordinates from `tripoint_rel_sm`->`tripoint_bub_sm`. 2. Update calls to `get_submap_at_grid` to specify whether the point is already inbounds-checked or not. These two changes are described below: 1. Change to `tripoint_bub_sm` So, we want to use one of the `_ib` types. Coordinates to specify a position for a submap used `tripoint_rel_sm` before this commit. But `_rel_sm` has no inbounds `_ib` type. It shouldn't. Saying that a relative coordinate is inbounds doesn't make sense - it only makes sense if we also specify another point to where it is relative to. One such point is the bubble reference. This commit therefore changes coordinates that specify a submap so that they instead use `tripoint_bub_sm`. This is in fact a stronger statement about the coordinate type - now we're saying that the coordinate is relative to the bubble. Before, when using `tripoint_rel_sm`, the type did not explicitly state what it was relative to (but before, it was always implicitly relative to the bubble anyway). `_bub_sm` also has an `_ib` type, so this commit uses `tripoint_bub_sm_ib` to specify coordinates for submaps where we've already inbounds-checked it before. 2. Update calls to `get_submap_at_grid` The method `get_submap_at_grid` takes a submap coordinate and returns the submap. In some of the places where we call this method, we can be sure that the point is in fact inbounds, for example: * when having called `inbounds()` just before, such as in `map::get_submap_at( const tripoint & )` * When iterating xy between `0` and `my_MAPSIZE` This commit therefore updates the places where it is obvious that the point is already bounds-checked so that `get_submap_at_grid` is called with `tripoint_bub_sm_ib` (inbound). The other overloaded version of `get_submap_at_grid` that takes `tripoint_bub_sm` still does inbounds checking.
- Loading branch information