Optimize containsKey -> get pattern
This commit is contained in:
committed by
TeamCityServer
parent
82591bb107
commit
c13822a2c5
@@ -485,19 +485,19 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
AccessorKey key = new AccessorKey(descriptor, superCallTarget, accessorKind);
|
||||
|
||||
// NB should check for property accessor factory first (or change property accessor tracking under propertyAccessorFactory creation)
|
||||
if (propertyAccessorFactories.containsKey(key)) {
|
||||
return (D) propertyAccessorFactories.get(key).getOrCreateAccessorIfNeeded(getterAccessorRequired, setterAccessorRequired);
|
||||
AccessorForPropertyDescriptorFactory propertyAccessorFactory = propertyAccessorFactories.get(key);
|
||||
if (propertyAccessorFactory != null) {
|
||||
return (D) propertyAccessorFactory.getOrCreateAccessorIfNeeded(getterAccessorRequired, setterAccessorRequired);
|
||||
}
|
||||
|
||||
if (accessors.containsKey(key)) {
|
||||
AccessorForCallableDescriptor<?> accessor = accessors.get(key);
|
||||
AccessorForCallableDescriptor<?> accessor = accessors.get(key);
|
||||
if (accessor != null) {
|
||||
assert accessorKind == AccessorKind.NORMAL ||
|
||||
accessor instanceof AccessorForPropertyBackingField : "There is already exists accessor with isForBackingField = false in this context";
|
||||
return (D) accessor;
|
||||
}
|
||||
|
||||
String nameSuffix = SyntheticAccessorUtilKt.getAccessorNameSuffix(descriptor, key.superCallLabelTarget, accessorKind);
|
||||
AccessorForCallableDescriptor<?> accessor;
|
||||
if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||
accessor = new AccessorForFunctionDescriptor((FunctionDescriptor) descriptor, contextDescriptor, superCallTarget, nameSuffix, accessorKind);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ public class RemappingClassBuilder extends DelegatingClassBuilder {
|
||||
@Nullable String signature,
|
||||
@Nullable Object value
|
||||
) {
|
||||
if (spilledCoroutineVariables.containsKey(name)) return spilledCoroutineVariables.get(name);
|
||||
FieldVisitor spilledCoroutineVariable = spilledCoroutineVariables.get(name);
|
||||
if (spilledCoroutineVariable != null) return spilledCoroutineVariable;
|
||||
|
||||
FieldRemapper field = new FieldRemapper(
|
||||
builder.newField(origin, access, name, this.remapper.mapDesc(desc), this.remapper.mapSignature(signature, true), value),
|
||||
|
||||
@@ -30,7 +30,7 @@ class TypeRemapper private constructor(
|
||||
private val typeParametersMapping = hashMapOf<String, TypeParameter>()
|
||||
|
||||
fun addMapping(type: String, newType: String) {
|
||||
typeMapping.put(type, newType)
|
||||
typeMapping[type] = newType
|
||||
}
|
||||
|
||||
fun hasNoAdditionalMapping(type: String): Boolean {
|
||||
|
||||
+3
-2
@@ -111,9 +111,10 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
signatures: MultiMap<RawSignature, JvmDeclarationOrigin>
|
||||
) {
|
||||
for (predefinedSignature in PREDEFINED_SIGNATURES) {
|
||||
if (!signatures.containsKey(predefinedSignature)) continue
|
||||
val signature = signatures[predefinedSignature]
|
||||
if (signature.isEmpty()) continue
|
||||
|
||||
val origins = signatures[predefinedSignature] + JvmDeclarationOrigin.NO_ORIGIN
|
||||
val origins = signature + JvmDeclarationOrigin.NO_ORIGIN
|
||||
|
||||
val diagnostic = computeDiagnosticToReport(classOrigin, classInternalName, predefinedSignature, origins) ?: continue
|
||||
diagnostics.report(ErrorsJvm.CONFLICTING_INHERITED_JVM_DECLARATIONS.on(diagnostic.element, diagnostic.data))
|
||||
|
||||
@@ -51,12 +51,16 @@ public class StringSwitchCodegen extends SwitchCodegen {
|
||||
assert constant instanceof StringValue : "guaranteed by usage contract";
|
||||
int hashCode = constant.hashCode();
|
||||
|
||||
List<StringSwitchCodegen.Entry> hashCodesToEntry;
|
||||
if (!transitionsTable.containsKey(hashCode)) {
|
||||
transitionsTable.put(hashCode, new Label());
|
||||
hashCodesToEntries.put(hashCode, new ArrayList<>());
|
||||
hashCodesToEntry = new ArrayList<>();
|
||||
hashCodesToEntries.put(hashCode, hashCodesToEntry);
|
||||
} else {
|
||||
hashCodesToEntry = hashCodesToEntries.get(hashCode);
|
||||
}
|
||||
|
||||
hashCodesToEntries.get(hashCode).add(new Entry(((StringValue) constant).getValue(), entryLabel, entry));
|
||||
hashCodesToEntry.add(new Entry(((StringValue) constant).getValue(), entryLabel, entry));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user