From 9cb2eaf3bee74d505b1330fbc14b162f9707fbdd Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 26 Apr 2019 13:33:13 +0200 Subject: [PATCH] Cache h3 content --- .../wiiu/jnus/implementations/NUSDataProviderFST.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/de/mas/wiiu/jnus/implementations/NUSDataProviderFST.java b/src/de/mas/wiiu/jnus/implementations/NUSDataProviderFST.java index 19a3aff..609da37 100644 --- a/src/de/mas/wiiu/jnus/implementations/NUSDataProviderFST.java +++ b/src/de/mas/wiiu/jnus/implementations/NUSDataProviderFST.java @@ -19,6 +19,8 @@ package de.mas.wiiu.jnus.implementations; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import de.mas.wiiu.jnus.Settings; @@ -49,9 +51,16 @@ public class NUSDataProviderFST implements NUSDataProvider { return fstDataProvider.readFileAsStream(contentFile, offset, size); } + Map> h3Hashes = new HashMap<>(); + @Override public Optional getContentH3Hash(Content content) throws IOException { - return readFileByFilename(base, String.format("%08X%s", content.getID(), Settings.H3_EXTENTION)); + Optional res = h3Hashes.get(content.getID()); + if(res == null) { + res =readFileByFilename(base, String.format("%08X%s", content.getID(), Settings.H3_EXTENTION)); + h3Hashes.put(content.getID(), res); + } + return res; } private Optional readFileByFilename(FSTEntry base, String filename) throws IOException {