Skip to content

Commit 7f32d66

Browse files
committed
Got rid of TObjectIntHashMap and TIntObjectHashMap usages
1 parent 31c151c commit 7f32d66

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

.idea/codeInsightSettings.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/core/src/main/java/com/perl5/lang/perl/idea/codeInsight/typeInference/value/PerlValueDeserializer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.perl5.lang.perl.idea.codeInsight.typeInference.value;
1818

1919
import com.intellij.psi.stubs.StubInputStream;
20-
import gnu.trove.TIntObjectHashMap;
20+
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
2121
import org.jetbrains.annotations.NotNull;
2222
import org.jetbrains.annotations.Nullable;
2323

@@ -30,7 +30,7 @@
3030
public class PerlValueDeserializer {
3131

3232
private final @NotNull StubInputStream myInputStream;
33-
private final TIntObjectHashMap<PerlValue> myDryMap = new TIntObjectHashMap<>();
33+
private final Int2ObjectOpenHashMap<PerlValue> myDryMap = new Int2ObjectOpenHashMap<>();
3434

3535
public PerlValueDeserializer(@NotNull StubInputStream inputStream) {
3636
myInputStream = inputStream;

plugin/core/src/main/java/com/perl5/lang/perl/idea/codeInsight/typeInference/value/PerlValueSerializer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.perl5.lang.perl.idea.codeInsight.typeInference.value;
1818

1919
import com.intellij.psi.stubs.StubOutputStream;
20-
import gnu.trove.TObjectIntHashMap;
20+
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
2121
import org.jetbrains.annotations.NotNull;
2222
import org.jetbrains.annotations.Nullable;
2323

@@ -26,7 +26,7 @@
2626

2727
final class PerlValueSerializer {
2828
private final @NotNull StubOutputStream myOutputStream;
29-
private final TObjectIntHashMap<PerlValue> myDryMap = new TObjectIntHashMap<>();
29+
private final Object2IntOpenHashMap<PerlValue> myDryMap = new Object2IntOpenHashMap<>();
3030

3131
public PerlValueSerializer(@NotNull StubOutputStream outputStream) {
3232
myOutputStream = outputStream;
@@ -37,7 +37,7 @@ void writeValue(@NotNull PerlValue value) throws IOException {
3737
writeVarInt(value.getSerializationId());
3838
return;
3939
}
40-
int duplicateId = myDryMap.get(value);
40+
int duplicateId = myDryMap.getInt(value);
4141
if (duplicateId > 0) {
4242
writeVarInt(PerlValuesManager.DUPLICATE_ID);
4343
writeVarInt(duplicateId);

plugin/core/src/main/java/com/perl5/lang/perl/idea/formatter/PurePerlFormattingContext.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
import com.perl5.lang.perl.psi.PerlSignatureElement;
4444
import com.perl5.lang.perl.psi.PsiPerlStatementModifier;
4545
import com.perl5.lang.perl.psi.utils.PerlPsiUtil;
46-
import gnu.trove.TIntIntHashMap;
47-
import gnu.trove.TIntObjectHashMap;
46+
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
47+
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
4848
import org.jetbrains.annotations.Contract;
4949
import org.jetbrains.annotations.NotNull;
5050
import org.jetbrains.annotations.Nullable;
@@ -64,7 +64,7 @@ public class PurePerlFormattingContext extends PerlBaseFormattingContext {
6464
private static final Logger LOG = Logger.getInstance(PurePerlFormattingContext.class);
6565
private final Map<ASTNode, Wrap> myWrapMap = new HashMap<>();
6666
private final Map<Integer, Alignment> myAssignmentsAlignmentsMap = new HashMap<>();
67-
private final TIntObjectHashMap<Alignment> myCommentsAlignmentMap = new TIntObjectHashMap<>();
67+
private final Int2ObjectOpenHashMap<Alignment> myCommentsAlignmentMap = new Int2ObjectOpenHashMap<>();
6868
private final Map<ASTNode, Alignment> myRightwardCallsAlignmentMap = FactoryMap.create(sequence -> Alignment.createAlignment(true));
6969
private final Map<ASTNode, Alignment> myOperatorsAlignmentsMap = FactoryMap.create(sequence -> Alignment.createAlignment(true));
7070
private final Map<ASTNode, Alignment> myElementsALignmentsMap = FactoryMap.create(sequence -> Alignment.createAlignment(true));
@@ -99,7 +99,7 @@ else if (StringUtil.containsLineBreak(run.getChars())) {
9999
}
100100

101101
int commentLine = getNodeLine(commentNode);
102-
if (myCommentsAlignmentMap.contains(commentLine)) {
102+
if (myCommentsAlignmentMap.containsKey(commentLine)) {
103103
return myCommentsAlignmentMap.get(commentLine);
104104
}
105105
if (LOG.isDebugEnabled()) {
@@ -140,7 +140,7 @@ else if (StringUtil.containsLineBreak(run.getChars())) {
140140
/**
141141
* Maps line numbers to the offset of first here-doc openers. Or {@link Integer.MAX_VALUE} if there is none
142142
*/
143-
private final TIntIntHashMap myHeredocForbiddenOffsets = new TIntIntHashMap();
143+
private final Int2IntOpenHashMap myHeredocForbiddenOffsets = new Int2IntOpenHashMap();
144144

145145
private static final MultiMap<IElementType, IElementType> OPERATOR_COLLISIONS_MAP = new MultiMap<>();
146146

@@ -205,7 +205,7 @@ public boolean isNewLineForbiddenAt(@NotNull ASTNode node) {
205205
return true;
206206
}
207207
int nodeLine = getNodeLine(node);
208-
if (myHeredocForbiddenOffsets.contains(nodeLine)) {
208+
if (myHeredocForbiddenOffsets.containsKey(nodeLine)) {
209209
return node.getStartOffset() > myHeredocForbiddenOffsets.get(nodeLine);
210210
}
211211

plugin/core/src/main/java/com/perl5/lang/perl/psi/stubs/PerlPolyNamedElementType.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
package com.perl5.lang.perl.psi.stubs;
1818

1919
import com.intellij.lang.ASTNode;
20+
import com.intellij.openapi.diagnostic.Logger;
2021
import com.intellij.psi.PsiElement;
2122
import com.intellij.psi.stubs.*;
2223
import com.intellij.util.containers.ContainerUtil;
2324
import com.perl5.lang.perl.PerlLanguage;
2425
import com.perl5.lang.perl.parser.elementTypes.PsiElementProvider;
2526
import com.perl5.lang.perl.psi.impl.PerlPolyNamedElement;
26-
import gnu.trove.TIntObjectHashMap;
27-
import gnu.trove.TObjectIntHashMap;
27+
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
28+
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
2829
import org.jetbrains.annotations.NotNull;
2930

3031
import java.io.IOException;
@@ -36,8 +37,9 @@
3637

3738
public abstract class PerlPolyNamedElementType<Stub extends PerlPolyNamedElementStub<Psi>, Psi extends PerlPolyNamedElement<Stub>>
3839
extends IStubElementType<Stub, Psi> implements PsiElementProvider {
39-
private static final TObjectIntHashMap<IStubElementType<?, ?>> DIRECT_MAP = new TObjectIntHashMap<>();
40-
private static final TIntObjectHashMap<IStubElementType<?, ?>> REVERSE_MAP = new TIntObjectHashMap<>();
40+
private static final Logger LOG = Logger.getInstance(PerlPolyNamedElementType.class);
41+
private static final Object2IntOpenHashMap<IStubElementType<?, ?>> DIRECT_MAP = new Object2IntOpenHashMap<>();
42+
private static final Int2ObjectOpenHashMap<IStubElementType<?, ?>> REVERSE_MAP = new Int2ObjectOpenHashMap<>();
4143

4244
static {
4345
// 0 is reserved for n/a
@@ -46,12 +48,9 @@ public abstract class PerlPolyNamedElementType<Stub extends PerlPolyNamedElement
4648
DIRECT_MAP.put(LIGHT_METHOD_DEFINITION, 3);
4749
DIRECT_MAP.put(CLASS_ACCESSOR_METHOD, 4);
4850
DIRECT_MAP.put(LIGHT_ATTRIBUTE_DEFINITION, 5);
49-
assert DIRECT_MAP.size() == 5;
51+
LOG.assertTrue(DIRECT_MAP.size() == 5);
5052

51-
DIRECT_MAP.forEachEntry((type, id) -> {
52-
REVERSE_MAP.put(id, type);
53-
return true;
54-
});
53+
DIRECT_MAP.forEach((type, id) -> REVERSE_MAP.put(id.intValue(), type));
5554
}
5655

5756
public PerlPolyNamedElementType(@NotNull String debugName) {

0 commit comments

Comments
 (0)