mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-28 22:47:41 +02:00
Reducing allocations count when working with bounding boxes (#843)
This commit is contained in:
parent
4c8b4c1abc
commit
eebdb4a7a3
@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public final class BoundingBox implements Shape {
|
||||
private final double width, height, depth;
|
||||
private final Point offset;
|
||||
private Point relativeEnd;
|
||||
|
||||
BoundingBox(double width, double height, double depth, Point offset) {
|
||||
this.width = width;
|
||||
@ -73,7 +74,9 @@ public final class BoundingBox implements Shape {
|
||||
|
||||
@Override
|
||||
public @NotNull Point relativeEnd() {
|
||||
return offset.add(width, height, depth);
|
||||
Point relativeEnd = this.relativeEnd;
|
||||
if (relativeEnd == null) this.relativeEnd = relativeEnd = offset.add(width, height, depth);
|
||||
return relativeEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user