From b2c0d94db1ec3d939c5e64a5ad42c9d42a5fbb91 Mon Sep 17 00:00:00 2001 From: CharlesVaneenoo Date: Thu, 25 Feb 2016 16:58:41 +0100 Subject: [PATCH] Simplify the getter of Crcs --- cache/src/main/org/apollo/cache/IndexedFileSystem.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cache/src/main/org/apollo/cache/IndexedFileSystem.java b/cache/src/main/org/apollo/cache/IndexedFileSystem.java index 2435a09d..1b59d9de 100644 --- a/cache/src/main/org/apollo/cache/IndexedFileSystem.java +++ b/cache/src/main/org/apollo/cache/IndexedFileSystem.java @@ -163,13 +163,11 @@ public final class IndexedFileSystem implements Closeable { * @throws IOException If there is an error accessing files to create the table. */ public int[] getCrcs() throws IOException { - if (crcs != null) { - return crcs; + if (crcs == null) { + ByteBuffer buffer = getCrcTable(); + crcs = new int[(buffer.remaining() / Integer.BYTES) - 1]; + Arrays.setAll(crcs, crc -> buffer.getInt()); } - - ByteBuffer buffer = getCrcTable(); - crcs = new int[(buffer.remaining() / Integer.BYTES) - 1]; - Arrays.setAll(crcs, crc -> buffer.getInt()); return crcs; }