File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -112,18 +112,12 @@ impl TileGrid {
112
112
}
113
113
114
114
fn insert_to_tile ( & mut self , entity : Entity , tile_coords : IVec2 ) {
115
- match self . tiles . get_mut ( & tile_coords) {
116
- Some ( tile) => {
117
- let inserted = tile. insert ( entity) ;
118
- debug_assert ! ( inserted) ;
119
- }
120
- None => {
121
- let mut tile = AHashSet :: new ( ) ;
122
- tile. insert ( entity) ;
123
- let old = self . tiles . insert ( tile_coords, tile) ;
124
- debug_assert ! ( old. is_none( ) ) ;
125
- }
126
- }
115
+ let inserted = self
116
+ . tiles
117
+ . entry ( tile_coords)
118
+ . or_insert_with ( AHashSet :: new)
119
+ . insert ( entity) ;
120
+ debug_assert ! ( inserted) ;
127
121
}
128
122
129
123
fn remove_from_tile ( & mut self , entity : Entity , tile_coords : IVec2 ) {
Original file line number Diff line number Diff line change @@ -132,12 +132,10 @@ impl Merger {
132
132
133
133
fn insert ( & mut self , exclusion : ExclusionArea ) {
134
134
let key = self . key ( & exclusion) ;
135
- match self . grid . get_mut ( & key) {
136
- Some ( exclusions) => exclusions. push ( exclusion) ,
137
- None => {
138
- self . grid . insert ( key, vec ! [ exclusion] ) ;
139
- }
140
- }
135
+ self . grid
136
+ . entry ( key)
137
+ . or_insert_with ( Vec :: new)
138
+ . push ( exclusion) ;
141
139
}
142
140
143
141
fn remove_intersecting ( & mut self , exclusion : & ExclusionArea ) -> Vec < ExclusionArea > {
You can’t perform that action at this time.
0 commit comments