From e96024793604267992d10f764c8ea5c32c87057a Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 18 Jun 2013 18:46:33 +0400 Subject: [PATCH] Useless class IndexedSymbolTable removed --- .../serialization/IndexedSymbolTable.java | 45 ------------------- .../serialization/TypeDeserializer.java | 20 ++++++--- 2 files changed, 13 insertions(+), 52 deletions(-) delete mode 100644 compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/IndexedSymbolTable.java diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/IndexedSymbolTable.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/IndexedSymbolTable.java deleted file mode 100644 index 3bb137303fd..00000000000 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/IndexedSymbolTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.descriptors.serialization; - -import gnu.trove.TIntObjectHashMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class IndexedSymbolTable { - @Nullable - private final IndexedSymbolTable parent; - private final TIntObjectHashMap symbols = new TIntObjectHashMap(); - - public IndexedSymbolTable(@Nullable IndexedSymbolTable parent) { - this.parent = parent; - } - - public void registerSymbol(int id, @NotNull T symbol) { - symbols.put(id, symbol); - } - - @Nullable - public T getSymbol(int id) { - T symbol = symbols.get(id); - if (symbol == null && parent != null) { - return parent.getSymbol(id); - } - return symbol; - } - -} diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java index 55b4c136ea0..966c969d21f 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java @@ -36,12 +36,16 @@ import java.util.List; public class TypeDeserializer { private final NameResolver nameResolver; private final ClassResolver classResolver; - private final IndexedSymbolTable typeParameterDescriptors; + private final TypeDeserializer parent; + private final TIntObjectHashMap typeParameterDescriptors = new TIntObjectHashMap(); private final TIntObjectHashMap classDescriptors = new TIntObjectHashMap(); private final String debugName; - public TypeDeserializer(@NotNull TypeDeserializer parent, @NotNull String debugName) { + public TypeDeserializer( + @NotNull TypeDeserializer parent, + @NotNull String debugName + ) { this(parent, parent.nameResolver, parent.classResolver, debugName); } @@ -50,9 +54,8 @@ public class TypeDeserializer { @NotNull NameResolver nameResolver, @NotNull ClassResolver classResolver, @NotNull String debugName - ) { - IndexedSymbolTable parentTypeParameters = parent == null ? null : parent.typeParameterDescriptors; - this.typeParameterDescriptors = new IndexedSymbolTable(parentTypeParameters); + ) { + this.parent = parent; this.nameResolver = nameResolver; this.classResolver = classResolver; this.debugName = debugName + (parent == null ? "" : ". Child of " + parent.debugName); @@ -64,7 +67,7 @@ public class TypeDeserializer { } public void registerTypeParameter(int id, TypeParameterDescriptor typeParameter) { - typeParameterDescriptors.registerSymbol(id, typeParameter); + typeParameterDescriptors.put(id, typeParameter); } @Nullable @@ -102,7 +105,10 @@ public class TypeDeserializer { return classDescriptor.getTypeConstructor(); case TYPE_PARAMETER: - TypeParameterDescriptor descriptor = typeParameterDescriptors.getSymbol(proto.getId()); + TypeParameterDescriptor descriptor = typeParameterDescriptors.get(proto.getId()); + if (descriptor == null && parent != null) { + descriptor = parent.typeParameterDescriptors.get(proto.getId()); + } if (descriptor == null) return null; return descriptor.getTypeConstructor();