From af13faa786a66062b0a03e6f522392258682e2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 23 Nov 2014 16:38:14 +0100 Subject: [PATCH] separated deobfuscation cache for AS1/2 and AS3 identifiers --- .../decompiler/flash/IdentifiersDeobfuscation.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java index b755dad1a..135546c60 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; +import com.jpexs.helpers.Cache; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -288,7 +289,8 @@ public class IdentifiersDeobfuscation { return "\u00A7" + escapeOIdentifier(s) + "\u00A7"; } - private static final Map nameCache = new HashMap<>(); + private static final Cache as3NameCache = Cache.getInstance(false); + private static final Cache as2NameCache = Cache.getInstance(false); /** * Ensures identifier is valid and if not, uses paragraph syntax @@ -309,9 +311,13 @@ public class IdentifiersDeobfuscation { return s; } } - if (nameCache.containsKey(s)) { + Cache nameCache = as3?as3NameCache:as2NameCache; + + + if (nameCache.contains(s)) { return nameCache.get(s); } + if (isValidName(as3, s, validExceptions)) { nameCache.put(s, s); return s; @@ -322,7 +328,8 @@ public class IdentifiersDeobfuscation { } public static String printNamespace(boolean as3, String pkg, String... validNameExceptions) { - if (nameCache.containsKey(pkg)) { + Cache nameCache = as3?as3NameCache:as2NameCache; + if (nameCache.contains(pkg)) { return nameCache.get(pkg); } if (pkg.isEmpty()) {