Skip to content

Commit 1d79443

Browse files
author
bytekeeper
committed
Tiny bit faster and comprehensible.
1 parent 403fbf0 commit 1d79443

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/main/java/bwem/Graph.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,16 @@ void createAreas(final List<Pair<WalkPosition, Integer>> areasList) {
257257
// ----------------------------------------------------------------------
258258
// 1) size the matrix
259259
// ----------------------------------------------------------------------
260-
private void initializeChokePointsMatrix(
261-
final List<List<List<ChokePoint>>> chokePointsMatrix, final int areasCount) {
260+
private void initializeChokePointsMatrix() {
261+
int areasCount = getAreaCount();
262262
chokePointsMatrix.clear();
263-
for (int i = 0; i < areasCount + 1; ++i) {
264-
chokePointsMatrix.add(new ArrayList<>());
265-
}
263+
// Unused due to ids starting at 1
264+
chokePointsMatrix.add(null);
266265
for (int id = 1; id <= areasCount; ++id) { // triangular matrix
266+
ArrayList<List<ChokePoint>> subList = new ArrayList<>();
267+
chokePointsMatrix.add(subList);
267268
for (int n = 0; n < id; ++n) {
268-
chokePointsMatrix.get(id).add(new ArrayList<>());
269+
subList.add(new ArrayList<>());
269270
}
270271
}
271272
}
@@ -332,7 +333,7 @@ public void createChokePoints(
332333
// }
333334

334335
// 1) size the matrix
335-
initializeChokePointsMatrix(this.chokePointsMatrix, getAreaCount());
336+
initializeChokePointsMatrix();
336337

337338
// 2) Dispatch the global raw frontier between all the relevant pairs of areas:
338339
final java.util.Map<Pair<AreaId, AreaId>, List<WalkPosition>> rawFrontierByAreaPair =

0 commit comments

Comments
 (0)