From e355ae9ef50bb18e707cd54309c73b55581a5c28 Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Mon, 5 Oct 2015 10:26:24 +0200 Subject: [PATCH] Optimised distanceTo in Location to perform better --- src/resources/Location.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/Location.java b/src/resources/Location.java index 11e1e62bf..f22500eee 100644 --- a/src/resources/Location.java +++ b/src/resources/Location.java @@ -289,6 +289,6 @@ public class Location implements Encodable, Serializable { double deltaY = destination.getY() - getY(); double deltaZ = destination.getZ() - getZ(); - return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2) + Math.pow(deltaZ, 2)); + return Math.sqrt(square(deltaX) + square(deltaY) + square(deltaZ)); } }