Minor optimization

This commit is contained in:
Valentin Kipyatkov
2015-06-11 16:12:56 +03:00
parent db0f212b3e
commit 060aeb60e1
@@ -88,13 +88,6 @@ public class WritableScopeImpl(override val workerScope: JetScope,
return result return result
} }
private fun getLabelsToDescriptors(): MutableMap<Name, MutableList<DeclarationDescriptor>> {
if (labelsToDescriptors == null) {
labelsToDescriptors = HashMap()
}
return labelsToDescriptors!!
}
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> { override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> {
checkMayRead() checkMayRead()
@@ -107,10 +100,10 @@ public class WritableScopeImpl(override val workerScope: JetScope,
override fun addLabeledDeclaration(descriptor: DeclarationDescriptor) { override fun addLabeledDeclaration(descriptor: DeclarationDescriptor) {
checkMayWrite() checkMayWrite()
val labelsToDescriptors = getLabelsToDescriptors() if (labelsToDescriptors == null) {
val name = descriptor.getName() labelsToDescriptors = HashMap()
var declarationDescriptors = labelsToDescriptors.getOrPut(name) { ArrayList() } }
declarationDescriptors.add(descriptor) labelsToDescriptors!!.getOrPut(descriptor.getName()) { ArrayList(1) }.add(descriptor)
} }
private fun addVariableOrClassDescriptor(descriptor: DeclarationDescriptor) { private fun addVariableOrClassDescriptor(descriptor: DeclarationDescriptor) {