From 03deddf6661903e0163978da26e2ac22deeb842d Mon Sep 17 00:00:00 2001 From: tom lee Date: Sat, 26 Feb 2022 14:04:49 +0800 Subject: [PATCH] Optimized the McObjectConverter for Direction --- .../lod/common/wrappers/McObjectConverter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java b/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java index 31614b123..154e402bc 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/McObjectConverter.java @@ -47,8 +47,18 @@ public class McObjectConverter } + static final Direction[] directions; + static { + LodDirection[] lodDirs = LodDirection.values(); + directions = new Direction[lodDirs.length]; + for (LodDirection lodDir : lodDirs) { + directions[lodDir.ordinal()] = Direction.byName(lodDir.name()); + } + } + + public static Direction Convert(LodDirection lodDirection) { - return Direction.byName(lodDirection.name()); + return directions[lodDirection.ordinal()]; } }