From dac24e8bf1c14b21c54364541b3255c104cdaade Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 23 Aug 2020 10:20:34 -0400 Subject: [PATCH] Replaced redundant 'negate' operator with *= -1 --- core/src/mindustry/logic/LAssembler.java | 14 ++++++++++---- core/src/mindustry/logic/LogicOp.java | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/mindustry/logic/LAssembler.java b/core/src/mindustry/logic/LAssembler.java index ceda4050a7..699b965c77 100644 --- a/core/src/mindustry/logic/LAssembler.java +++ b/core/src/mindustry/logic/LAssembler.java @@ -120,10 +120,16 @@ public class LAssembler{ }else if(type.equals("uop")){ arr[0] = "op"; - //field order for uop used to be op a, result, but now it's op result a - String res = arr[3]; - arr[3] = arr[2]; - arr[2] = res; + if(arr[1].equals("negate")){ + arr = new String[]{ + "op", "mul", arr[3], arr[2], "-1" + }; + }else{ + //field order for uop used to be op a, result, but now it's op result a + String res = arr[3]; + arr[3] = arr[2]; + arr[2] = res; + } } LStatement st = LogicIO.read(arr); diff --git a/core/src/mindustry/logic/LogicOp.java b/core/src/mindustry/logic/LogicOp.java index b53a60d5de..23e0ce1956 100644 --- a/core/src/mindustry/logic/LogicOp.java +++ b/core/src/mindustry/logic/LogicOp.java @@ -25,7 +25,6 @@ public enum LogicOp{ atan2("atan2", (x, y) -> Mathf.atan2((float)x, (float)y) * Mathf.radDeg), dst("dst", (x, y) -> Mathf.dst((float)x, (float)y)), - negate("-", a -> -a), not("not", a -> ~(int)(a)), abs("abs", Math::abs), log("log", Math::log),