Remove streams from SensorNearest

The behavioural nearby sensors are validated every tick on the entities
that registered the respective sensors and are therefore a good subject
to performance improvements.

More specifically this commit replaces the Stream#filter usage with
ArrayList#removeIf as the removeIf method on an array list is heavily
optimized towards a single internal array re-allocation without any
further overhead on the removeIf call.

The only negative of this change is the rather agressive diff these
patches introduce as the methods are basically being reimplemented
compared to the previous stream-based implementation.

See: https://nipafx.dev/java-stream-performance/
Note: Updated LICENCE.md to release this commit under MIT
This commit is contained in:
Bjarne Koll
2021-03-03 03:52:43 +01:00
parent de5a2a4108
commit 64e1a54657
2 changed files with 119 additions and 0 deletions

View File

@@ -47,4 +47,5 @@ Nassim Jahnke <nassim@njahnke.dev>
Machine_Maker <machine@machinemaker.me>
Ivan Pekov <ivan@mrivanplays.com>
Camotoy <20743703+Camotoy@users.noreply.github.com>
Bjarne Koll <git@lynxplay.dev>
```