Description:
Two quick tweaks
Remove unnecessary HashShet and replace other HashSet with List.
Adding to a HashSet seems to be slower than adding to the List
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -114,8 +114,8 | |||||
|
114 | { |
|
114 | { |
|
115 |
|
115 | ||
|
116 | #region calculate_preserve_cells |
|
116 | #region calculate_preserve_cells |
|
117 | var preserve_cells = new HashSet<isometricparkfna.CellMap.Cell>(); |
|
117 | // var preserve_cells = new HashSet<isometricparkfna.CellMap.Cell>(); |
|
118 |
var preserve_cell_coordinates = new |
|
118 | var preserve_cell_coordinates = new List<(int, int)>(); |
|
119 | var count = 0; |
|
119 | var count = 0; |
|
120 |
|
120 | ||
|
121 | Stopwatch iterPreserves = new Stopwatch(); |
|
121 | Stopwatch iterPreserves = new Stopwatch(); |
@@ -125,7 +125,7 | |||||
|
125 | ref readonly var areaComponent = ref GetComponent<AreaComponent>(entity); |
|
125 | ref readonly var areaComponent = ref GetComponent<AreaComponent>(entity); |
|
126 |
|
126 | ||
|
127 | foreach (var square in areaComponent.squares) { |
|
127 | foreach (var square in areaComponent.squares) { |
|
128 | preserve_cells.Add(this.simulation.map.cells[(int)square.X][(int)square.Y]); |
|
128 | // preserve_cells.Add(this.simulation.map.cells[(int)square.X][(int)square.Y]); |
|
129 | preserve_cell_coordinates.Add(((int)square.X, (int)square.Y)); |
|
129 | preserve_cell_coordinates.Add(((int)square.X, (int)square.Y)); |
|
130 | } |
|
130 | } |
|
131 | } |
|
131 | } |
@@ -156,14 +156,10 | |||||
|
156 | //* |
|
156 | //* |
|
157 | foreach ((var x, var y) in preserve_cell_coordinates) { |
|
157 | foreach ((var x, var y) in preserve_cell_coordinates) { |
|
158 | foreach ((var newx, var newy) in this.simulation.map.iterate_neighbor_cell_locations(x, y)) { |
|
158 | foreach ((var newx, var newy) in this.simulation.map.iterate_neighbor_cell_locations(x, y)) { |
|
159 |
|
|||
|
160 | this.simulation.PreserveCounts[newx, newy] += 1; |
|
159 | this.simulation.PreserveCounts[newx, newy] += 1; |
|
161 | } |
|
160 | } |
|
162 |
|
|||
|
163 | } |
|
161 | } |
|
164 | //*/ |
|
162 | //*/ |
|
165 |
|
|||
|
166 |
|
|||
|
167 | iterCells.Stop(); |
|
163 | iterCells.Stop(); |
|
168 | Logging.Info(String.Format("Cell loop: {0:F3}", iterCells.Elapsed.TotalMilliseconds.ToString())); |
|
164 | Logging.Info(String.Format("Cell loop: {0:F3}", iterCells.Elapsed.TotalMilliseconds.ToString())); |
|
169 |
|
165 |
You need to be logged in to leave comments.
Login now