Int2ObjectMap<DFAType> (@NotNull Int2ObjectMap<DFAType> cached, @Nullable TypeDfaState candidate) { if (candidate == null || candidate.getRawVarTypes().isEmpty()) { return cached; } List<Int2ObjectMap.Entry<DFAType>> newTypes = new SmartList<>(); for (Int2ObjectMap.Entry<DFAType> candidateEntry : candidate.getRawVarTypes().int2ObjectEntrySet()) { int index = candidateEntry.getIntKey(); if (candidate.isProhibited(index) || (cached.containsKey(index) && checkDfaStatesConsistency(cached, candidateEntry))) { continue; } newTypes.add(candidateEntry); } if (newTypes.isEmpty()) { return cached; } Int2ObjectMap<DFAType> newState = new Int2ObjectOpenHashMap<>(cached.size() + newTypes.size()); newState.putAll(cached); for (var entry : newTypes) { newState.put(entry.getIntKey(), entry.getValue()); } return newState; }