GP-4712 Simplified code putting prototype into map

This commit is contained in:
emteere 2024-07-31 10:25:53 -04:00
parent 35cbc81d59
commit 4ff585d8db

View File

@ -375,16 +375,12 @@ public class SleighLanguage implements Language {
new SleighInstructionPrototype(this, buf, context, contextcache, inDelaySlot, null); new SleighInstructionPrototype(this, buf, context, contextcache, inDelaySlot, null);
Integer hashcode = newProto.hashCode(); Integer hashcode = newProto.hashCode();
// check proto map for already defined prototype // get existing proto and use it
res = instructProtoMap.get(hashcode); // if doesn't exist in map, cache info and store new proto
if (res == null) { res = instructProtoMap.computeIfAbsent(hashcode, h -> {
newProto.cacheInfo(buf, context, true); newProto.cacheInfo(buf, context, true);
res = instructProtoMap.putIfAbsent(hashcode, newProto); return newProto;
// if there was no previous value, assume newProto inserted });
if (res == null) {
res = newProto;
}
}
if (inDelaySlot && res.hasDelaySlots()) { if (inDelaySlot && res.hasDelaySlots()) {
throw new NestedDelaySlotException(); throw new NestedDelaySlotException();