diff --git a/.idea/libraries/fastutil_min.xml b/.idea/libraries/fastutil_min.xml index aa1533ee4045..582b096d1f03 100644 --- a/.idea/libraries/fastutil_min.xml +++ b/.idea/libraries/fastutil_min.xml @@ -1,9 +1,9 @@ - + - - 1d36e528b8fa8e878ec4bf28e7c6acc374a89336b96e9bed7ebf735b1787febd + + 19d613c22adbaf9cef204d2f4d6f17afe1389087f80728c04aa982c62b5a2cf3 @@ -11,11 +11,11 @@ - + - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index cb8048f00a1d..0ad7db32164b 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -905,6 +905,7 @@ + diff --git a/build/tasks/src/org/jetbrains/intellij/build/ConsoleSpanExporter.kt b/build/tasks/src/org/jetbrains/intellij/build/ConsoleSpanExporter.kt index d567959e46cc..9c895dffeddf 100644 --- a/build/tasks/src/org/jetbrains/intellij/build/ConsoleSpanExporter.kt +++ b/build/tasks/src/org/jetbrains/intellij/build/ConsoleSpanExporter.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. @file:Suppress("ReplaceJavaStaticMethodWithKotlinAnalog", "ReplaceNegatedIsEmptyWithIsNotEmpty") package org.jetbrains.intellij.build @@ -195,7 +195,7 @@ private fun formatDuration(duration: Long): java.lang.StringBuilder { if (count < multiplier) break val remainder = count % multiplier count /= multiplier - if (remainder != 0L || !unitValues.isEmpty) { + if (remainder != 0L || !unitValues.isEmpty()) { unitValues.add(0, remainder) unitIndices.add(0, i - 1) } diff --git a/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainSearcher.java b/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainSearcher.java index a6fe79e5d51a..d5b1ecce7f76 100644 --- a/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainSearcher.java +++ b/java/compiler/impl/src/com/intellij/compiler/chainsSearch/ChainSearcher.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.compiler.chainsSearch; import com.intellij.compiler.backwardRefs.CompilerReferenceServiceEx; @@ -6,7 +6,6 @@ import com.intellij.compiler.chainsSearch.context.ChainCompletionContext; import com.intellij.compiler.chainsSearch.context.ChainSearchTarget; import com.intellij.openapi.progress.ProgressManager; import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.backwardRefs.CompilerRef; import org.jetbrains.jps.backwardRefs.SignatureData; @@ -163,7 +162,7 @@ public final class ChainSearcher { return; } boolean doAdd = true; - IntStack indicesToRemove = new IntArrayList(); + @SuppressWarnings("SSBasedInspection") IntArrayList indicesToRemove = new IntArrayList(); for (int i = 0; i < result.size(); i++) { OperationChain chain = result.get(i); OperationChain.CompareResult r = OperationChain.compare(chain, newChain); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/asm/DFSTree.java b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/asm/DFSTree.java index 6da0c57d6707..ca506c2a61ce 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/asm/DFSTree.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/bytecodeAnalysis/asm/DFSTree.java @@ -1,6 +1,7 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.bytecodeAnalysis.asm; +import it.unimi.dsi.fastutil.longs.LongIterator; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; public final class DFSTree { @@ -37,7 +38,11 @@ public final class DFSTree { } private static void iterate(LongOpenHashSet set, EdgeVisitor visitor) { - set.forEach(packed -> visitor.visit((int)(packed >>> 32), (int)(packed))); + LongIterator iterator = set.iterator(); + while (iterator.hasNext()) { + long packed = iterator.nextLong(); + visitor.visit((int)(packed >>> 32), (int)(packed)); + } } private static void putEdge(LongOpenHashSet set, int from, int to) { diff --git a/java/java-frontback-psi-impl/src/com/intellij/lang/java/lexer/BasicJavaLexer.java b/java/java-frontback-psi-impl/src/com/intellij/lang/java/lexer/BasicJavaLexer.java index b2cc23af7b27..4b9a01c3210d 100644 --- a/java/java-frontback-psi-impl/src/com/intellij/lang/java/lexer/BasicJavaLexer.java +++ b/java/java-frontback-psi-impl/src/com/intellij/lang/java/lexer/BasicJavaLexer.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.lang.java.lexer; import com.intellij.lexer.LexerBase; @@ -9,7 +9,6 @@ import com.intellij.psi.impl.source.AbstractBasicJavaDocElementTypeFactory; import com.intellij.psi.tree.IElementType; import com.intellij.util.text.CharArrayUtil; import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,7 +20,8 @@ public class BasicJavaLexer extends LexerBase { private static final int STATE_TEXT_BLOCK_TEMPLATE = 1; private final _JavaLexer myFlexLexer; - private final IntStack myStateStack = new IntArrayList(1); + @SuppressWarnings("SSBasedInspection") + private final IntArrayList myStateStack = new IntArrayList(1); private CharSequence myBuffer; private char @Nullable [] myBufferArray; private int myBufferIndex; diff --git a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java index f438a3b6b020..70f05adda38c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.psi.controlFlow; import com.intellij.codeInsight.ExceptionUtil; @@ -10,7 +10,10 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; -import it.unimi.dsi.fastutil.ints.*; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.ints.IntSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,14 +57,12 @@ public final class ControlFlowUtil { } } - @NotNull - public static List getSSAVariables(@NotNull ControlFlow flow) { + public static @NotNull List getSSAVariables(@NotNull ControlFlow flow) { return getSSAVariables(flow, 0, flow.getSize(), false); } - @NotNull - public static List getSSAVariables(@NotNull ControlFlow flow, int from, int to, - boolean reportVarsIfNonInitializingPathExists) { + public static @NotNull List getSSAVariables(@NotNull ControlFlow flow, int from, int to, + boolean reportVarsIfNonInitializingPathExists) { List instructions = flow.getInstructions(); Collection writtenVariables = getWrittenVariables(flow, from, to, false); List result = new ArrayList<>(1); @@ -178,8 +179,7 @@ public final class ControlFlowUtil { return visitor.getResult().booleanValue(); } - @NotNull - public static Collection getWrittenVariables(@NotNull ControlFlow flow, int start, int end, final boolean ignoreNotReachingWrites) { + public static @NotNull Collection getWrittenVariables(@NotNull ControlFlow flow, int start, int end, final boolean ignoreNotReachingWrites) { Set set = new HashSet<>(); getWrittenVariables(flow, start, end, ignoreNotReachingWrites, set); return set; @@ -199,8 +199,7 @@ public final class ControlFlowUtil { } } - @NotNull - public static List getUsedVariables(@NotNull ControlFlow flow, int start, int end) { + public static @NotNull List getUsedVariables(@NotNull ControlFlow flow, int start, int end) { List array = new ArrayList<>(); if (start < 0) return array; List instructions = flow.getInstructions(); @@ -320,8 +319,7 @@ public final class ControlFlowUtil { return false; } - @NotNull - public static List getInputVariables(@NotNull ControlFlow flow, int start, int end) { + public static @NotNull List getInputVariables(@NotNull ControlFlow flow, int start, int end) { List usedVariables = getUsedVariables(flow, start, end); List array = new ArrayList<>(usedVariables.size()); for (PsiVariable variable : usedVariables) { @@ -353,10 +351,9 @@ public final class ControlFlowUtil { } @SafeVarargs - @NotNull - public static Collection findExitPointsAndStatements(@NotNull ControlFlow flow, final int start, final int end, - @NotNull IntList exitPoints, - Class @NotNull ... classesFilter) { + public static @NotNull Collection findExitPointsAndStatements(@NotNull ControlFlow flow, final int start, final int end, + @NotNull IntList exitPoints, + Class @NotNull ... classesFilter) { if (end == start) { exitPoints.add(end); return Collections.emptyList(); @@ -503,15 +500,14 @@ public final class ControlFlowUtil { * In the same example {@code hasObservableThrowExitPoints(theOuterBlock) == false}, * because no outgoing variables here depend on the exceptions being thrown. */ - public static boolean hasObservableThrowExitPoints(@NotNull final ControlFlow flow, + public static boolean hasObservableThrowExitPoints(final @NotNull ControlFlow flow, final int flowStart, final int flowEnd, PsiElement @NotNull [] elements, @NotNull PsiElement enclosingCodeFragment) { final List instructions = flow.getInstructions(); class Worker { - @NotNull - private Map getWritesOffsets() { + private @NotNull Map getWritesOffsets() { final Map writeOffsets = new HashMap<>(); for (int i = flowStart; i < flowEnd; i++) { Instruction instruction = instructions.get(i); @@ -528,8 +524,7 @@ public final class ControlFlowUtil { return writeOffsets; } - @NotNull - private Map getVisibleReadsOffsets(@NotNull Map writeOffsets, @NotNull PsiCodeBlock tryBlock) { + private @NotNull Map getVisibleReadsOffsets(@NotNull Map writeOffsets, @NotNull PsiCodeBlock tryBlock) { final Map visibleReadOffsets = new HashMap<>(); for (PsiVariable variable : writeOffsets.keySet()) { if (!PsiTreeUtil.isAncestor(tryBlock, variable, true)) { @@ -552,9 +547,8 @@ public final class ControlFlowUtil { return visibleReadOffsets; } - @NotNull - private Map> getReachableAfterWrite(@NotNull Map writeOffsets, - @NotNull Map visibleReadOffsets) { + private @NotNull Map> getReachableAfterWrite(@NotNull Map writeOffsets, + @NotNull Map visibleReadOffsets) { final Map> afterWrite = new HashMap<>(); final IntFunction calculator = getReachableInstructionsCalculator(); for (PsiVariable variable : visibleReadOffsets.keySet()) { @@ -597,8 +591,7 @@ public final class ControlFlowUtil { return afterWrite; } - @NotNull - private IntList getCatchOrFinallyOffsets(@NotNull List tryStatements, @NotNull List thrownExceptions) { + private @NotNull IntList getCatchOrFinallyOffsets(@NotNull List tryStatements, @NotNull List thrownExceptions) { final IntList catchOrFinallyOffsets = new IntArrayList(); for (PsiTryStatement tryStatement : tryStatements) { final PsiCodeBlock finallyBlock = tryStatement.getFinallyBlock(); @@ -640,8 +633,7 @@ public final class ControlFlowUtil { return false; } - @NotNull - private IntFunction getReachableInstructionsCalculator() { + private @NotNull IntFunction getReachableInstructionsCalculator() { final ControlFlowGraph graph = new ControlFlowGraph(flow.getSize()) { @Override void addArc(int offset, int nextOffset) { @@ -702,9 +694,8 @@ public final class ControlFlowUtil { return ContainerUtil.exists(tryStatement.getCatchBlockParameters(), (parameter) -> exceptionType.isAssignableFrom(exceptionType)); } - @Nullable - private static PsiTryStatement getEnclosingTryStatementHavingCatchOrFinally(@Nullable PsiElement startElement, - @NotNull PsiElement enclosingCodeFragment) { + private static @Nullable PsiTryStatement getEnclosingTryStatementHavingCatchOrFinally(@Nullable PsiElement startElement, + @NotNull PsiElement enclosingCodeFragment) { for (PsiElement element = startElement; element != null && element != enclosingCodeFragment; element = element.getParent()) { if (element instanceof PsiCodeBlock) { final PsiElement parent = element.getParent(); @@ -720,9 +711,8 @@ public final class ControlFlowUtil { return null; } - @NotNull - private static List collectTryStatementStack(@Nullable PsiElement startElement, - @NotNull PsiElement enclosingCodeFragment) { + private static @NotNull List collectTryStatementStack(@Nullable PsiElement startElement, + @NotNull PsiElement enclosingCodeFragment) { final List stack = new ArrayList<>(); for (PsiTryStatement tryStatement = getEnclosingTryStatementHavingCatchOrFinally(startElement, enclosingCodeFragment); tryStatement != null; @@ -732,8 +722,7 @@ public final class ControlFlowUtil { return stack; } - @NotNull - public static PsiElement findCodeFragment(@NotNull PsiElement element) { + public static @NotNull PsiElement findCodeFragment(@NotNull PsiElement element) { PsiElement codeFragment = element; PsiElement parent = codeFragment.getParent(); while (parent != null) { @@ -942,8 +931,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Boolean getResult() { + public @NotNull Boolean getResult() { return !isNormalCompletion[0]; } } @@ -1023,8 +1011,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Boolean getResult() { + public @NotNull Boolean getResult() { return !isNormalCompletion[startOffset]; } } @@ -1034,7 +1021,7 @@ public final class ControlFlowUtil { } /** - * returns true iff exists control flow path completing normally, i.e. not resulting in return,break,continue or exception thrown. + * Returns true iff exists control flow path completing normally, i.e. not resulting in return,break,continue or exception thrown. * In other words, if we add instruction after controlflow specified, it should be reachable */ public static boolean canCompleteNormally(@NotNull ControlFlow flow, final int startOffset, final int endOffset) { @@ -1116,8 +1103,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Boolean getResult() { + public @NotNull Boolean getResult() { return canCompleteNormally[startOffset]; } } @@ -1197,8 +1183,7 @@ public final class ControlFlowUtil { } } - @Nullable - private static PsiElement getUnreachableExpressionParent(@Nullable PsiElement element) { + private static @Nullable PsiElement getUnreachableExpressionParent(@Nullable PsiElement element) { if (element instanceof PsiExpression) { PsiElement expression = PsiTreeUtil.findFirstParent(element, e -> !(e.getParent() instanceof PsiParenthesizedExpression)); while (expression != null) { @@ -1242,8 +1227,7 @@ public final class ControlFlowUtil { return null; } - @Nullable - private static PsiElement getEnclosingUnreachableStatement(@NotNull PsiElement statement) { + private static @Nullable PsiElement getEnclosingUnreachableStatement(@NotNull PsiElement statement) { final PsiElement parent = statement.getParent(); if (parent instanceof PsiDoWhileStatement && ((PsiDoWhileStatement)parent).getBody() == statement) { return parent; @@ -1260,8 +1244,7 @@ public final class ControlFlowUtil { return getUnreachableStatementParent(statement); } - @Nullable - private static PsiElement getUnreachableStatementParent(@NotNull PsiElement statement) { + private static @Nullable PsiElement getUnreachableStatementParent(@NotNull PsiElement statement) { final PsiElement parent = statement.getParent(); if (parent instanceof PsiForStatement && ((PsiForStatement)parent).getInitialization() == statement) { return parent; @@ -1328,7 +1311,7 @@ public final class ControlFlowUtil { return !visitor.getResult(); } - public static boolean isVariableDefinitelyAssigned(@NotNull final PsiVariable variable, @NotNull final ControlFlow flow) { + public static boolean isVariableDefinitelyAssigned(final @NotNull PsiVariable variable, final @NotNull ControlFlow flow) { PsiElement parent = variable.getParent(); final int variableDeclarationOffset = parent == null ? -1 : flow.getStartOffset(parent); int offset = variableDeclarationOffset > -1 ? variableDeclarationOffset : 0; @@ -1460,8 +1443,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Boolean getResult() { + public @NotNull Boolean getResult() { return !maybeAssigned[0]; } } @@ -1506,8 +1488,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Boolean getResult() { + public @NotNull Boolean getResult() { return maybeReferenced[start]; } } @@ -1553,8 +1534,7 @@ public final class ControlFlowUtil { * @param start starting instruction offset * @return a list of edges */ - @NotNull - public static List getEdges(@NotNull ControlFlow flow, int start) { + public static @NotNull List getEdges(@NotNull ControlFlow flow, int start) { final List list = new ArrayList<>(); depthFirstSearch(flow, new InstructionClientVisitor() { @Override @@ -1595,8 +1575,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Integer getResult() { + public @NotNull Integer getResult() { int minOffset = flow.getSize(); int maxExitPoints = 0; nextOffset: @@ -1820,8 +1799,7 @@ public final class ControlFlowUtil { private static class CopyOnWriteList { private final List list; - @NotNull - public CopyOnWriteList add(@NotNull VariableInfo value) { + public @NotNull CopyOnWriteList add(@NotNull VariableInfo value) { CopyOnWriteList newList = new CopyOnWriteList(); List list = getList(); for (final VariableInfo variableInfo : list) { @@ -1833,8 +1811,7 @@ public final class ControlFlowUtil { return newList; } - @NotNull - public CopyOnWriteList remove(@NotNull VariableInfo value) { + public @NotNull CopyOnWriteList remove(@NotNull VariableInfo value) { CopyOnWriteList newList = new CopyOnWriteList(); List list = getList(); for (final VariableInfo variableInfo : list) { @@ -1845,8 +1822,7 @@ public final class ControlFlowUtil { return newList; } - @NotNull - public List getList() { + public @NotNull List getList() { return list; } @@ -1862,8 +1838,7 @@ public final class ControlFlowUtil { list = new SmartList<>(infos); } - @NotNull - public CopyOnWriteList addAll(@NotNull CopyOnWriteList addList) { + public @NotNull CopyOnWriteList addAll(@NotNull CopyOnWriteList addList) { CopyOnWriteList newList = new CopyOnWriteList(); List list = getList(); newList.list.addAll(list); @@ -1877,8 +1852,7 @@ public final class ControlFlowUtil { return newList; } - @NotNull - public static CopyOnWriteList add(@Nullable CopyOnWriteList list, @NotNull VariableInfo value) { + public static @NotNull CopyOnWriteList add(@Nullable CopyOnWriteList list, @NotNull VariableInfo value) { return list == null ? new CopyOnWriteList(value) : list.add(value); } } @@ -1911,20 +1885,17 @@ public final class ControlFlowUtil { /** * @return list of PsiReferenceExpression of usages of non-initialized local variables */ - @NotNull - public static List getReadBeforeWriteLocals(@NotNull ControlFlow flow) { + public static @NotNull List getReadBeforeWriteLocals(@NotNull ControlFlow flow) { final InstructionClientVisitor> visitor = new ReadBeforeWriteClientVisitor(flow, true); depthFirstSearch(flow, visitor); return visitor.getResult(); } - @NotNull - public static List getReadBeforeWrite(@NotNull ControlFlow flow) { + public static @NotNull List getReadBeforeWrite(@NotNull ControlFlow flow) { return getReadBeforeWrite(flow, 0); } - @NotNull - private static List getReadBeforeWrite(@NotNull ControlFlow flow, int startOffset) { + private static @NotNull List getReadBeforeWrite(@NotNull ControlFlow flow, int startOffset) { if (startOffset < 0 || startOffset >= flow.getSize()) { return Collections.emptyList(); } @@ -1996,13 +1967,11 @@ public final class ControlFlowUtil { } @Override - @NotNull - public List getResult() { + public @NotNull List getResult() { return getResult(0); } - @NotNull - public List getResult(int startOffset) { + public @NotNull List getResult(int startOffset) { final CopyOnWriteList topReadVariables = readVariables[startOffset]; if (topReadVariables == null) return Collections.emptyList(); @@ -2050,8 +2019,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Integer getResult() { + public @NotNull Integer getResult() { return (returnCalled[offset] ? RETURN_COMPLETION_REASON : 0) | (normalCompletion[offset] ? NORMAL_COMPLETION_REASON : 0); } } @@ -2061,13 +2029,11 @@ public final class ControlFlowUtil { return visitor.getResult().intValue(); } - @NotNull - public static Collection getInitializedTwice(@NotNull ControlFlow flow) { + public static @NotNull Collection getInitializedTwice(@NotNull ControlFlow flow) { return getInitializedTwice(flow, 0, flow.getSize()); } - @NotNull - public static Collection getInitializedTwice(@NotNull ControlFlow flow, int startOffset, int endOffset) { + public static @NotNull Collection getInitializedTwice(@NotNull ControlFlow flow, int startOffset, int endOffset) { while (startOffset < endOffset) { InitializedTwiceClientVisitor visitor = new InitializedTwiceClientVisitor(flow, startOffset); depthFirstSearch(flow, visitor, startOffset, endOffset); @@ -2117,8 +2083,7 @@ public final class ControlFlowUtil { merge(offset, writeTwiceVars, writtenTwiceVariables); } - @Nullable - private static PsiElement getExpression(@NotNull PsiElement element) { + private static @Nullable PsiElement getExpression(@NotNull PsiElement element) { if (element instanceof PsiAssignmentExpression) { PsiExpression target = PsiUtil.skipParenthesizedExprDown(((PsiAssignmentExpression)element).getLExpression()); return ObjectUtils.tryCast(target, PsiReferenceExpression.class); @@ -2134,8 +2099,7 @@ public final class ControlFlowUtil { return null; } - @Nullable - private static PsiElement getLatestWriteVarExpression(@Nullable CopyOnWriteList writeVars, @NotNull PsiVariable variable) { + private static @Nullable PsiElement getLatestWriteVarExpression(@Nullable CopyOnWriteList writeVars, @NotNull PsiVariable variable) { if (writeVars == null) return null; PsiManager psiManager = variable.getManager(); @@ -2148,8 +2112,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Collection getResult() { + public @NotNull Collection getResult() { final CopyOnWriteList writtenTwiceVariable = writtenTwiceVariables[myStartOffset]; if (writtenTwiceVariable == null) return Collections.emptyList(); return writtenTwiceVariable.getList(); @@ -2162,8 +2125,7 @@ public final class ControlFlowUtil { * @param stopPoint point until which reads are considered * @return locations of writes */ - @NotNull - public static Map getWritesBeforeReads(@NotNull ControlFlow flow, + public static @NotNull Map getWritesBeforeReads(@NotNull ControlFlow flow, @NotNull Set writeVars, @NotNull Set readVars, final int stopPoint) { @@ -2188,7 +2150,7 @@ public final class ControlFlowUtil { * * @return true if it was read */ - private static boolean readBeforeStopPoint(@NotNull final ControlFlow flow, + private static boolean readBeforeStopPoint(final @NotNull ControlFlow flow, @NotNull Set readVars, final int startOffset, final int stopPoint) { @@ -2231,11 +2193,11 @@ public final class ControlFlowUtil { /** * @return true if instruction at 'instructionOffset' is reachable from offset 'startOffset' */ - public static boolean isInstructionReachable(@NotNull final ControlFlow flow, final int instructionOffset, final int startOffset) { + public static boolean isInstructionReachable(final @NotNull ControlFlow flow, final int instructionOffset, final int startOffset) { return areInstructionsReachable(flow, new int[]{instructionOffset}, startOffset); } - private static boolean areInstructionsReachable(@NotNull final ControlFlow flow, + private static boolean areInstructionsReachable(final @NotNull ControlFlow flow, final int @NotNull [] instructionOffsets, final int startOffset) { class MyVisitor extends InstructionClientVisitor { @@ -2247,8 +2209,7 @@ public final class ControlFlowUtil { } @Override - @NotNull - public Boolean getResult() { + public @NotNull Boolean getResult() { return reachable; } } @@ -2341,7 +2302,7 @@ public final class ControlFlowUtil { boolean depthFirstSearch(final int startOffset, @NotNull BitSet visitedOffsets) { // traverse the graph starting with the startOffset - IntStack walkThroughStack=new IntArrayList(Math.max(size() / 2, 2)); + IntArrayList walkThroughStack = new IntArrayList(Math.max(size() / 2, 2)); visitedOffsets.clear(); walkThroughStack.push(startOffset); while (!walkThroughStack.isEmpty()) { @@ -2371,12 +2332,12 @@ public final class ControlFlowUtil { } void buildFrom(@NotNull ControlFlow flow) { - // traverse the whole flow in order to collect the graph edges + // traverse the whole flow to collect the graph edges ControlFlowUtil.depthFirstSearch(flow, this, 0, flow.getSize()); } } - private static boolean areInstructionsReachableWithCalls(@NotNull final ControlFlow flow, + private static boolean areInstructionsReachableWithCalls(final @NotNull ControlFlow flow, final int @NotNull [] instructionOffsets, final int startOffset) { ControlFlowGraph graph = new ControlFlowGraph(flow.getSize()) { @@ -2418,7 +2379,7 @@ public final class ControlFlowUtil { return catchType.isAssignableFrom(throwType) || mightBeAssignableFromSubclass(throwType, catchType); } - private static boolean mightBeAssignableFromSubclass(@NotNull final PsiClassType throwType, @NotNull PsiType catchType) { + private static boolean mightBeAssignableFromSubclass(final @NotNull PsiClassType throwType, @NotNull PsiType catchType) { if (catchType instanceof PsiDisjunctionType) { for (PsiType catchDisjunction : ((PsiDisjunctionType)catchType).getDisjunctions()) { if (throwType.isAssignableFrom(catchDisjunction)) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildProgress.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildProgress.java index 2707b761dd1f..02711e49b8f0 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildProgress.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/messages/BuildProgress.java @@ -1,10 +1,11 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.jps.incremental.messages; import com.intellij.openapi.diagnostic.Logger; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectIterator; import org.jetbrains.jps.FreezeDetector; import org.jetbrains.jps.builders.BuildTarget; import org.jetbrains.jps.builders.BuildTargetIndex; @@ -158,7 +159,10 @@ public final class BuildProgress { LOG.debug("update expected build time for " + myTotalBuildTimeForFullyRebuiltTargets.size() + " target types"); } - myTotalBuildTimeForFullyRebuiltTargets.object2LongEntrySet().fastForEach(entry -> { + ObjectIterator>> iterator = + myTotalBuildTimeForFullyRebuiltTargets.object2LongEntrySet().fastIterator(); + while (iterator.hasNext()) { + Object2LongMap.Entry> entry = iterator.next(); BuildTargetType type = entry.getKey(); long totalTime = entry.getLongValue(); BuildTargetsState targetsState = myDataManager.getTargetsState(); @@ -176,7 +180,7 @@ public final class BuildProgress { + " of " + myTotalTargets.getInt(type) + " targets)"); } targetsState.setAverageBuildTime(type, newAverageTime); - }); + } } public synchronized long getAbsoluteBuildTime() { diff --git a/platform/build-scripts/codeOptimizer/Makefile b/platform/build-scripts/codeOptimizer/Makefile new file mode 100644 index 000000000000..18a87bc8df4e --- /dev/null +++ b/platform/build-scripts/codeOptimizer/Makefile @@ -0,0 +1,31 @@ +VERSION := 8.5.13 + +install: + mvn install:install-file -DgroupId=org.jetbrains.intellij.deps.fastutil \ + -DartifactId=intellij-deps-fastutil \ + -Dversion=$(VERSION) \ + -Dpackaging=jar \ + -Dfile=out/fastutil.jar + mvn install:install-file -DgroupId=org.jetbrains.intellij.deps.fastutil \ + -DartifactId=intellij-deps-fastutil \ + -Dversion=$(VERSION) \ + -Dpackaging=java-source \ + -DgeneratePom=false \ + -Dfile=out/fastutil-sources.jar + +deploy: install + mvn deploy:deploy-file -DgroupId=org.jetbrains.intellij.deps.fastutil \ + -DartifactId=intellij-deps-fastutil \ + -Dversion=$(VERSION) \ + -Dpackaging=jar \ + -Dfile=out/fastutil.jar \ + -DrepositoryId=space-intellij-dependencies \ + -Durl=https://packages.jetbrains.team/maven/p/ij/intellij-dependencies + mvn deploy:deploy-file -DgroupId=org.jetbrains.intellij.deps.fastutil \ + -DartifactId=intellij-deps-fastutil \ + -Dversion=$(VERSION) \ + -DgeneratePom=false \ + -Dpackaging=java-source \ + -Dfile=out/fastutil-sources.jar \ + -DrepositoryId=space-intellij-dependencies \ + -Durl=https://packages.jetbrains.team/maven/p/ij/intellij-dependencies \ No newline at end of file diff --git a/platform/build-scripts/codeOptimizer/intellij.platform.buildScripts.codeOptimizer.iml b/platform/build-scripts/codeOptimizer/intellij.platform.buildScripts.codeOptimizer.iml new file mode 100644 index 000000000000..602f94e3cff7 --- /dev/null +++ b/platform/build-scripts/codeOptimizer/intellij.platform.buildScripts.codeOptimizer.iml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + 8a3a9837da14881ccdd189cabe9069fd7ffa9fffc69387fdd4f7f3682781e498 + + + 1882b17ceaeff14c89e74903dd2aa47af57f85d574ea98ea008bc1b9db53f5f1 + + + 5ccb24ad9f92e768d0bc456d3061a737951262df803e004d2cad096b75a88d60 + + + b4a1796fab7bfc36df015c1b4052459147997e8d215a7199d71d05f9e747e4f4 + + + 57d65f5883bd65fa41e6d06cb7dcaceb73a49338bb8a4611c9e22d2a3f674a97 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platform/build-scripts/codeOptimizer/readme.md b/platform/build-scripts/codeOptimizer/readme.md new file mode 100644 index 000000000000..37d5ab779725 --- /dev/null +++ b/platform/build-scripts/codeOptimizer/readme.md @@ -0,0 +1 @@ +The obfuscating library makes the API simpler by limiting it to only approved classes. This prevents mistakes, like using the wrong class, for example, the fastutil `Pair`. \ No newline at end of file diff --git a/platform/build-scripts/codeOptimizer/src/fastutil.conf b/platform/build-scripts/codeOptimizer/src/fastutil.conf new file mode 100644 index 000000000000..cad2fb72972d --- /dev/null +++ b/platform/build-scripts/codeOptimizer/src/fastutil.conf @@ -0,0 +1,172 @@ +-libraryjars /jmods/java.base.jmod(!**.jar;!module-info.class) +-libraryjars /jmods/java.logging.jmod(!**.jar;!module-info.class) +-libraryjars /jmods/java.xml.jmod(!**.jar;!module-info.class) + +-keep ,includedescriptorclasses public class + it.unimi.dsi.fastutil.objects.AbstractObjectIterator, + it.unimi.dsi.fastutil.AbstractObjectSet, + it.unimi.dsi.fastutil.Hash, + it.unimi.dsi.fastutil.Hash$Strategy, + it.unimi.dsi.fastutil.HashCommon, + it.unimi.dsi.fastutil.Arrays, + it.unimi.dsi.fastutil.Swapper, + it.unimi.dsi.fastutil.Stack, + + it.unimi.dsi.fastutil.bytes.ByteArrayList, + it.unimi.dsi.fastutil.bytes.ByteArrays, + + it.unimi.dsi.fastutil.doubles.Double2ObjectMap, + it.unimi.dsi.fastutil.doubles.Double2ObjectMap$Entry, + it.unimi.dsi.fastutil.doubles.Double2ObjectMaps, + it.unimi.dsi.fastutil.doubles.Double2ObjectOpenHashMap, + it.unimi.dsi.fastutil.doubles.DoubleArrayList, + it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet, + + it.unimi.dsi.fastutil.floats.FloatArrayList, + it.unimi.dsi.fastutil.floats.FloatList, + + it.unimi.dsi.fastutil.ints.AbstractInt2ObjectMap, + it.unimi.dsi.fastutil.ints.AbstractIntIterator, + it.unimi.dsi.fastutil.ints.AbstractIntList, + it.unimi.dsi.fastutil.ints.AbstractIntSet, + it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2ByteOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2IntMap, + it.unimi.dsi.fastutil.ints.Int2IntMap$FastEntrySet, + it.unimi.dsi.fastutil.ints.Int2IntMap$Entry, + it.unimi.dsi.fastutil.ints.Int2IntMaps, + it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap, + it.unimi.dsi.fastutil.ints.Int2LongMap, + it.unimi.dsi.fastutil.ints.Int2LongMap$Entry, + it.unimi.dsi.fastutil.ints.Int2LongMap$FastEntrySet, + it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2LongRBTreeMap, + it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2ObjectMap, + it.unimi.dsi.fastutil.ints.Int2ObjectMap$Entry, + it.unimi.dsi.fastutil.ints.Int2ObjectMap$FastEntrySet, + it.unimi.dsi.fastutil.ints.Int2ObjectMaps, + it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap, + it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap, + it.unimi.dsi.fastutil.ints.IntArrayList, + it.unimi.dsi.fastutil.ints.IntArraySet, + it.unimi.dsi.fastutil.ints.IntBinaryOperator, + it.unimi.dsi.fastutil.ints.IntCollection, + it.unimi.dsi.fastutil.ints.IntComparator, + it.unimi.dsi.fastutil.ints.IntConsumer, + it.unimi.dsi.fastutil.ints.IntIterable, + it.unimi.dsi.fastutil.ints.IntIterators, + it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet, + it.unimi.dsi.fastutil.ints.IntList, + it.unimi.dsi.fastutil.ints.IntLists, + it.unimi.dsi.fastutil.ints.IntOpenHashSet, + it.unimi.dsi.fastutil.ints.IntRBTreeSet, + it.unimi.dsi.fastutil.ints.IntSet, + it.unimi.dsi.fastutil.ints.IntSets, + it.unimi.dsi.fastutil.ints.IntStack, + it.unimi.dsi.fastutil.ints.Int2LongMaps, + it.unimi.dsi.fastutil.ints.IntAVLTreeSet, + it.unimi.dsi.fastutil.ints.IntImmutableList, + it.unimi.dsi.fastutil.ints.IntComparators, + it.unimi.dsi.fastutil.ints.IntSortedSets, + it.unimi.dsi.fastutil.ints.Int2FloatMap, + it.unimi.dsi.fastutil.ints.Int2FloatMap$Entry, + it.unimi.dsi.fastutil.ints.Int2FloatMap$FastEntrySet, + it.unimi.dsi.fastutil.ints.IntArrays, + + it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap, + it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap, + it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap, + it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap, + it.unimi.dsi.fastutil.longs.Long2ObjectMap, + it.unimi.dsi.fastutil.longs.Long2ObjectMap$Entry, + it.unimi.dsi.fastutil.longs.Long2ObjectMap$FastEntrySet, + it.unimi.dsi.fastutil.longs.Long2ObjectMaps, + it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap, + it.unimi.dsi.fastutil.longs.LongArrayList, + it.unimi.dsi.fastutil.longs.LongIterable, + it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet, + it.unimi.dsi.fastutil.longs.LongList, + it.unimi.dsi.fastutil.longs.LongOpenHashSet, + it.unimi.dsi.fastutil.longs.LongSet, + it.unimi.dsi.fastutil.longs.LongSets, + it.unimi.dsi.fastutil.longs.LongArraySet, + it.unimi.dsi.fastutil.longs.Long2IntFunction, + + it.unimi.dsi.fastutil.booleans.BooleanArrayList, + + it.unimi.dsi.fastutil.objects.AbstractObjectSet, + it.unimi.dsi.fastutil.objects.ObjectSet, + it.unimi.dsi.fastutil.objects.Object2BooleanOpenCustomHashMap, + it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap, + it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap, + it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap, + it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap, + + it.unimi.dsi.fastutil.objects.Object2IntMap, + it.unimi.dsi.fastutil.objects.Object2IntMap$Entry, + it.unimi.dsi.fastutil.objects.Object2IntMap$FastEntrySet, + it.unimi.dsi.fastutil.objects.Object2IntMaps, + it.unimi.dsi.fastutil.objects.Object2IntOpenCustomHashMap, + it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap, + + it.unimi.dsi.fastutil.objects.Object2LongMap, + it.unimi.dsi.fastutil.objects.Object2LongMap$Entry, + it.unimi.dsi.fastutil.objects.Object2LongMap$FastEntrySet, + it.unimi.dsi.fastutil.objects.Object2LongMaps, + it.unimi.dsi.fastutil.objects.Object2LongOpenCustomHashMap, + it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap, + + it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap, + it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenCustomHashMap, + it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap, + it.unimi.dsi.fastutil.objects.Object2ObjectMaps, + it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap, + it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap, + it.unimi.dsi.fastutil.objects.Object2ShortOpenHashMap, + it.unimi.dsi.fastutil.objects.ObjectArrayList, + it.unimi.dsi.fastutil.objects.ObjectArrays, + it.unimi.dsi.fastutil.objects.ObjectArraySet, + it.unimi.dsi.fastutil.objects.Object2DoubleMap, + it.unimi.dsi.fastutil.objects.Object2DoubleMap$Entry, + + it.unimi.dsi.fastutil.objects.Reference2IntMap, + it.unimi.dsi.fastutil.objects.Reference2IntMap$Entry, + it.unimi.dsi.fastutil.objects.Reference2IntMap$FastEntrySet, + it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap, + it.unimi.dsi.fastutil.objects.Reference2ObjectLinkedOpenHashMap, + it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap, + it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap, + it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet, + it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet, + + it.unimi.dsi.fastutil.objects.ObjectImmutableList, + it.unimi.dsi.fastutil.objects.ObjectIntImmutablePair, + it.unimi.dsi.fastutil.objects.ObjectIterators, + it.unimi.dsi.fastutil.objects.ObjectLinkedOpenCustomHashSet, + it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet, + it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet, + it.unimi.dsi.fastutil.objects.ObjectOpenHashSet { + public static *; + public *; + protected ; + protected (...); + protected void rehash(int); +} + +-keepparameternames +-renamesourcefileattribute SourceFile +-keepattributes Signature,Exceptions,*Annotation*, + InnerClasses,PermittedSubclasses,EnclosingMethod, + Deprecated,SourceFile,LineNumberTable + +-optimizationpasses 5 +-optimizeaggressively + +-keepclassmembers,allowoptimization enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} \ No newline at end of file diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/proguard/jsvg.conf b/platform/build-scripts/codeOptimizer/src/jsvg.conf similarity index 100% rename from platform/build-scripts/src/org/jetbrains/intellij/build/proguard/jsvg.conf rename to platform/build-scripts/codeOptimizer/src/jsvg.conf diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/proguard/optimizeLib.kt b/platform/build-scripts/codeOptimizer/src/optimizeLib.kt similarity index 59% rename from platform/build-scripts/src/org/jetbrains/intellij/build/proguard/optimizeLib.kt rename to platform/build-scripts/codeOptimizer/src/optimizeLib.kt index 141093d44fa8..b4b01ff77ed5 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/proguard/optimizeLib.kt +++ b/platform/build-scripts/codeOptimizer/src/optimizeLib.kt @@ -1,62 +1,63 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.intellij.build.proguard +package com.intellij.platform.buildScripts.codeOptimizer -import com.intellij.openapi.util.text.Formats -import com.intellij.util.io.DigestUtil.updateContentHash -import com.intellij.util.io.bytesToHex -import com.intellij.util.io.sha3_224 import org.apache.logging.log4j.core.LoggerContext import org.apache.logging.log4j.core.config.ConfigurationFactory import org.apache.logging.log4j.core.config.ConfigurationSource import org.apache.logging.log4j.core.config.NullConfiguration -import org.jetbrains.intellij.build.BuildTasks -import org.jetbrains.intellij.build.io.ZipFileWriter -import org.jetbrains.intellij.build.io.readZipFile import proguard.* -import java.nio.channels.FileChannel import java.nio.file.Files import java.nio.file.Path -import java.nio.file.StandardOpenOption +import java.nio.file.StandardCopyOption import java.util.* import kotlin.time.measureTime internal data class OptimizeLibraryContext(@JvmField val tempDir: Path, @JvmField val javaHome: Path) +// The Maven Java API can appear somewhat complex and broad, making certain tasks cumbersome. +// Hence, we depend on the prerequisite that the original library is already resolved and stored in the local Maven repository. internal object LibraryCodeOptimizer { @JvmStatic fun main(args: Array) { - val userHome = Path.of(System.getProperty("user.home")) - val m2 = userHome.resolve(".m2/repository") - val output = userHome.resolve("projects/jsvg.jar") + val m2 = Path.of(System.getProperty("user.home")).resolve(".m2/repository") + val outDir = Path.of("out").toAbsolutePath() + val output = outDir.resolve("fastutil.jar") if (Files.isRegularFile(output)) { Files.deleteIfExists(output) } - val input = m2.resolve("com/github/weisj/jsvg/1.3.0-jb.3/jsvg-1.3.0-jb.3.jar") + //val input = m2.resolve("com/github/weisj/jsvg/1.3.0-jb.3/jsvg-1.3.0-jb.3.jar") + val version = "8.5.13-jb.1" + val input = m2.resolve("it/unimi/dsi/fastutil/$version/fastutil-$version.jar") + val mapping = outDir.resolve("fastutil-map.txt") val duration = measureTime { - optimizeLibrary(name = "jsvg", + optimizeLibrary(name = "fastutil", input = input, output = output, javaHome = System.getProperty("java.home"), - mapping = null) + mapping = mapping) } - println(Formats.formatDuration(duration.inWholeMilliseconds)) + println(duration.inWholeMilliseconds) - val digest = sha3_224() - updateContentHash(digest, cleanZip(output)) - println(bytesToHex(digest.digest())) + Files.copy(m2.resolve("it/unimi/dsi/fastutil/$version/fastutil-$version-sources.jar"), + outDir.resolve("fastutil-sources.jar"), + StandardCopyOption.REPLACE_EXISTING) + + //val digest = sha3_224() + //updateContentHash(digest, cleanZip(output)) + //println(bytesToHex(digest.digest())) } } -private fun cleanZip(file: Path): Path { - val tempFile = Files.createTempFile(file.parent, file.fileName.toString(), ".jar") - ZipFileWriter(channel = FileChannel.open(tempFile, EnumSet.of(StandardOpenOption.WRITE))).use { zipFileWriter -> - readZipFile(file) { name, data -> - zipFileWriter.uncompressedData(name, data()) - } - } - return tempFile -} +//private fun cleanZip(file: Path): Path { +// val tempFile = Files.createTempFile(file.parent, file.fileName.toString(), ".jar") +// ZipFileWriter(channel = FileChannel.open(tempFile, EnumSet.of(StandardOpenOption.WRITE))).use { zipFileWriter -> +// readZipFile(file) { name, data -> +// zipFileWriter.uncompressedData(name, data()) +// } +// } +// return tempFile +//} // See LibraryCodeOptimizer above — it confirms that ProGuard produces the same result for the same input. // Thus, it is safe to apply ProGuard - builds are reproducible. @@ -65,7 +66,7 @@ internal fun optimizeLibrary(name: String, input: Path, output: Path, javaHome: val properties = Properties() properties.setProperty("java.home", javaHome) val configFileName = "$name.conf" - val configText = BuildTasks::class.java.classLoader.getResourceAsStream("org/jetbrains/intellij/build/proguard/$configFileName")?.use { + val configText = OptimizeLibraryContext::class.java.classLoader.getResourceAsStream(configFileName)?.use { it.readAllBytes().decodeToString() } ConfigurationParser(configText, configFileName, output.parent.toFile(), properties).use { diff --git a/platform/build-scripts/intellij.platform.buildScripts.iml b/platform/build-scripts/intellij.platform.buildScripts.iml index bf529bffea79..f0a988ad01ad 100644 --- a/platform/build-scripts/intellij.platform.buildScripts.iml +++ b/platform/build-scripts/intellij.platform.buildScripts.iml @@ -268,123 +268,57 @@ - + - - 4cf3ef5db8c8466224b436a1242e7d13c469a2582dd7a055ec65130c89a82ae8 + + deaca39f9ae12879f061c946d72641240e731dc9df0059d9b69472f43accb4a5 - - a16f0e6ec5915ed7b0f63b51f91d2fc8208dbed0d9abc38f8307e5594eb14acd + + ef116816a4d221933d34d9f113fd47f6780bca2b0c826545081d742f4e7178fb - - c0707395e4e63f67ea3533388ec6b5f403055b7a701449a35468a1c4966ac7af + + f2fee72e08fd510479ac93e7e33694bdbc465b32a56896bf1ab8a8dfba366f18 e3137c89b08d0c3d9f7dfeae11d5b941b310f5f7bfdea90063f29c0b3b1f6807 - - 691a0a605de15ea610180317331957fe6f7e91f45471ee45cbf9832d74291c31 - - - - - + - - - + - - - - - - - - - - - - + - - - - + + + + - - - + + + - - - - + + + - - - - - - - a4f71a8dde8be77cb84dc862dabd3322cc8c082a6d21489d96bd7cd9f3b673ff - - - a5f5462a98de7bc4a79408d6240ab18bd78ed0bfc0a559e20e1a9357949986b9 - - - 5ccb24ad9f92e768d0bc456d3061a737951262df803e004d2cad096b75a88d60 - - - b4a1796fab7bfc36df015c1b4052459147997e8d215a7199d71d05f9e747e4f4 - - - 57d65f5883bd65fa41e6d06cb7dcaceb73a49338bb8a4611c9e22d2a3f674a97 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuildContextImpl.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuildContextImpl.kt index ccab6a34da61..22f6c7d12fb7 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuildContextImpl.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/BuildContextImpl.kt @@ -312,7 +312,7 @@ class BuildContextImpl( } override suspend fun produce() { - buildJar(targetFile = targetFile, sources = sources, compress = compress, notify = false, optimizeLibraryContext = null) + buildJar(targetFile = targetFile, sources = sources, compress = compress, notify = false) } }, ) diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt index 5492586d8c3b..b6cb850f5e79 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/impl/JarPackager.kt @@ -686,7 +686,7 @@ private suspend fun buildJars(descriptors: Collection, return emptyMap() } - val optimizeLibraryContext = OptimizeLibraryContext(tempDir = context.paths.tempDir, javaHome = context.getStableJdkHome()) + //val optimizeLibraryContext = OptimizeLibraryContext(tempDir = context.paths.tempDir, javaHome = context.getStableJdkHome()) val list = withContext(Dispatchers.IO) { descriptors.map { item -> async { @@ -730,8 +730,7 @@ private suspend fun buildJars(descriptors: Collection, buildJar(targetFile = file, sources = sources, nativeFileHandler = nativeFileHandler, - notify = false, - optimizeLibraryContext = optimizeLibraryContext) + notify = false) } } ) diff --git a/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt b/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt index 1bcccb255abe..648bb820bcdd 100644 --- a/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt +++ b/platform/build-scripts/src/org/jetbrains/intellij/build/mergeJars.kt @@ -9,7 +9,6 @@ import io.opentelemetry.api.common.Attributes import io.opentelemetry.api.trace.Span import org.jetbrains.intellij.build.impl.projectStructureMapping.DistributionFileEntry import org.jetbrains.intellij.build.io.* -import org.jetbrains.intellij.build.proguard.OptimizeLibraryContext import java.nio.ByteBuffer import java.nio.file.Files import java.nio.file.Path @@ -144,15 +143,14 @@ internal interface NativeFileHandler { } suspend fun buildJar(targetFile: Path, sources: List, compress: Boolean = false) { - buildJar(targetFile = targetFile, sources = sources, compress = compress, nativeFileHandler = null, optimizeLibraryContext = null) + buildJar(targetFile = targetFile, sources = sources, compress = compress, nativeFileHandler = null) } internal suspend fun buildJar(targetFile: Path, sources: List, compress: Boolean = false, notify: Boolean = true, - nativeFileHandler: NativeFileHandler? = null, - optimizeLibraryContext: OptimizeLibraryContext?) { + nativeFileHandler: NativeFileHandler? = null) { val packageIndexBuilder = if (compress) null else PackageIndexBuilder() writeNewFile(targetFile) { outChannel -> ZipFileWriter(channel = outChannel, @@ -190,7 +188,7 @@ internal suspend fun buildJar(targetFile: Path, } is ZipSource -> { - var sourceFile = source.file + val sourceFile = source.file try { //if (source.optimizeConfigId != null) { // TraceManager.spanBuilder("optimize").setAttribute("library", source.optimizeConfigId).useWithoutActiveScope { @@ -222,6 +220,7 @@ internal suspend fun buildJar(targetFile: Path, compress = compress) } finally { + @Suppress("KotlinConstantConditions") if (sourceFile !== source.file) { Files.deleteIfExists(sourceFile) } diff --git a/platform/core-impl/src/com/intellij/codeInsight/controlflow/ControlFlowUtil.java b/platform/core-impl/src/com/intellij/codeInsight/controlflow/ControlFlowUtil.java index fdfb399f1f40..c5062e30e339 100644 --- a/platform/core-impl/src/com/intellij/codeInsight/controlflow/ControlFlowUtil.java +++ b/platform/core-impl/src/com/intellij/codeInsight/controlflow/ControlFlowUtil.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.controlflow; import com.intellij.openapi.progress.ProgressManager; @@ -7,7 +7,6 @@ import com.intellij.util.Function; import com.intellij.util.Processor; import com.intellij.util.graph.Graph; import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntStack; import org.jetbrains.annotations.NotNull; import java.util.Arrays; @@ -60,7 +59,8 @@ public final class ControlFlowUtil { boolean[] visited = new boolean[length]; Arrays.fill(visited, false); - final IntStack stack = new IntArrayList(length); + @SuppressWarnings("SSBasedInspection") + IntArrayList stack = new IntArrayList(length); stack.push(start); while (!stack.isEmpty()) { @@ -94,7 +94,8 @@ public final class ControlFlowUtil { final Instruction @NotNull [] instructions, final @NotNull Function closure, boolean prev) { - final IntStack stack = new IntArrayList(instructions.length); + //noinspection SSBasedInspection + final IntArrayList stack = new IntArrayList(instructions.length); final boolean[] visited = new boolean[instructions.length]; stack.push(startInstruction); @@ -103,7 +104,7 @@ public final class ControlFlowUtil { final int num = stack.popInt(); final Instruction instr = instructions[num]; final Operation nextOperation = closure.fun(instr); - // Just ignore previous instructions for current node and move further + // Just ignore previous instructions for the current node and move further if (nextOperation == Operation.CONTINUE) { continue; } diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistryImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistryImpl.java index b810250e37bd..6b8326f62bb0 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistryImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistryImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.psi.impl.source.resolve.reference; import com.intellij.lang.Language; @@ -160,7 +160,7 @@ public final class ReferenceProvidersRegistryImpl extends ReferenceProvidersRegi // if provider returns EMPTY_ARRAY or array with "null" references then this provider isn't added in priorities map. private static @NotNull Double2ObjectMap> mapNotEmptyReferencesFromProviders(@NotNull PsiElement context, @NotNull List> providers) { - Double2ObjectMap> map = new Double2ObjectOpenHashMap<>(); + Double2ObjectOpenHashMap> map = new Double2ObjectOpenHashMap<>(); for (ProviderBinding.ProviderInfo trinity : providers) { PsiReference[] refs = getReferences(context, trinity); if (refs.length > 0) { diff --git a/platform/diagnostic/src/StartUpMeasurer.java b/platform/diagnostic/src/StartUpMeasurer.java index 27987b12d092..655f442c128c 100644 --- a/platform/diagnostic/src/StartUpMeasurer.java +++ b/platform/diagnostic/src/StartUpMeasurer.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.diagnostic; import it.unimi.dsi.fastutil.objects.Object2LongMap; @@ -11,6 +11,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import java.util.function.LongBinaryOperator; public final class StartUpMeasurer { public static final long MEASURE_THRESHOLD = TimeUnit.MILLISECONDS.toNanos(10); @@ -237,7 +238,7 @@ public final class StartUpMeasurer { @NotNull Map> pluginCostMap) { Object2LongMap costPerPhaseMap = pluginCostMap.computeIfAbsent(pluginId, __ -> new Object2LongOpenHashMap<>()); synchronized (costPerPhaseMap) { - costPerPhaseMap.mergeLong(phase, time, Math::addExact); + costPerPhaseMap.mergeLong(phase, time, (LongBinaryOperator)Math::addExact); } } } diff --git a/platform/indexing-impl/src/com/intellij/util/indexing/FileBasedIndexEx.java b/platform/indexing-impl/src/com/intellij/util/indexing/FileBasedIndexEx.java index 6ffc0a01daf8..402d71a1ea7c 100644 --- a/platform/indexing-impl/src/com/intellij/util/indexing/FileBasedIndexEx.java +++ b/platform/indexing-impl/src/com/intellij/util/indexing/FileBasedIndexEx.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.indexing; import com.intellij.ide.lightEdit.LightEditCompatible; @@ -756,7 +756,7 @@ public abstract class FileBasedIndexEx extends FileBasedIndex { isFirst = false; } - return isFirst ? ObjectIterators.emptyIterator() : + return isFirst ? Collections.emptyIterator() : result instanceof VirtualFileWithId ? ObjectIterators.singleton(result) : null; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java index afb130656f5c..bfbd87dfb2f5 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/IndentsPass.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.TextEditorHighlightingPass; @@ -33,12 +33,12 @@ import com.intellij.psi.util.PsiUtilCore; import com.intellij.util.DocumentUtil; import com.intellij.util.text.CharArrayUtil; import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; import java.util.*; +@SuppressWarnings("SSBasedInspection") public final class IndentsPass extends TextEditorHighlightingPass implements DumbAware { private static final Key> INDENT_HIGHLIGHTERS_IN_EDITOR_KEY = Key.create("INDENT_HIGHLIGHTERS_IN_EDITOR_KEY"); private static final Key LAST_TIME_INDENTS_BUILT = Key.create("LAST_TIME_INDENTS_BUILT"); @@ -78,7 +78,7 @@ public final class IndentsPass extends TextEditorHighlightingPass implements Dum private long nowStamp() { if (!myEditor.getSettings().isIndentGuidesShown()) return -1; - // include tab size into stamp to make sure indent guides are recalculated on tab size change + // include tab size in stamp to make sure indent guides are recalculated on tab size change return myDocument.getModificationStamp() ^ (((long)getTabSize()) << 24); } @@ -105,7 +105,9 @@ public final class IndentsPass extends TextEditorHighlightingPass implements Dum while (curRange < myRanges.size() && curHighlight < oldHighlighters.size()) { TextRange range = myRanges.get(curRange); RangeHighlighter highlighter = oldHighlighters.get(curHighlight); - if (!highlighter.isValid()) break; + if (!highlighter.isValid()) { + break; + } int cmp = compare(range, highlighter); if (cmp < 0) { @@ -150,8 +152,8 @@ public final class IndentsPass extends TextEditorHighlightingPass implements Dum calculator.calculate(); int[] lineIndents = calculator.lineIndents; - IntStack lines = new IntArrayList(); - IntStack indents = new IntArrayList(); + IntArrayList lines = new IntArrayList(); + IntArrayList indents = new IntArrayList(); lines.push(0); indents.push(0); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/TimestampsImmutable.kt b/platform/lang-impl/src/com/intellij/util/indexing/TimestampsImmutable.kt index fb6fb9369ebb..9577f5092d83 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/TimestampsImmutable.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/TimestampsImmutable.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.indexing import com.intellij.openapi.application.ApplicationManager @@ -115,7 +115,7 @@ class TimestampsImmutable { upToDateIndexIds.add(stream.readInt()) } - if (upToDateIndexIds.isEmpty && outdatedIndices.isEmpty) { + if (upToDateIndexIds.isEmpty() && outdatedIndices.isEmpty()) { assert(dominatingIndexStamp == DataInputOutputUtil.timeBase) { "dominatingIndexStamp=$dominatingIndexStamp != timeBase=${DataInputOutputUtil.timeBase}" } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/hprof/analysis/AnalyzeGraph.kt b/platform/platform-impl/src/com/intellij/diagnostic/hprof/analysis/AnalyzeGraph.kt index 17681c5c6bb8..cbf331ea97d1 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/hprof/analysis/AnalyzeGraph.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/hprof/analysis/AnalyzeGraph.kt @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@file:Suppress("ReplaceGetOrSet") + package com.intellij.diagnostic.hprof.analysis import com.google.common.base.Stopwatch @@ -275,9 +277,9 @@ open class AnalyzeGraph(protected val analysisContext: AnalysisContext, private val sunMiscCleanerClass = classStore.getClassIfExists("sun.misc.Cleaner") val finalizerClass = classStore.getClassIfExists("java.lang.ref.Finalizer") - while (!toVisit.isEmpty) { + while (!toVisit.isEmpty()) { for (i in 0 until toVisit.size) { - val id = toVisit[i] + val id = toVisit.getInt(i) // Disposer.ourTree is only visited during DisposerTree phase to give opportunity for if (includeDisposerRelationships && @@ -398,14 +400,14 @@ open class AnalyzeGraph(protected val analysisContext: AnalysisContext, private // If no more object to visit at this phase, transition to the next while (toVisit.size == 0 && phase != WalkGraphPhase.Finished) { // Next state - phase = WalkGraphPhase.values()[phase.ordinal + 1] + phase = WalkGraphPhase.entries[phase.ordinal + 1] when (phase) { - WalkGraphPhase.StrongReferencesLocalVariables -> + WalkGraphPhase.StrongReferencesLocalVariables -> { frameRootsSet.forEach { id -> addIdToListAndSetParentIfOrphan(toVisit, id, id) - true } + } WalkGraphPhase.CleanerFinalizerReferences -> { toVisit.addAll(cleanerObjects) cleanerObjects.clear() @@ -466,7 +468,7 @@ open class AnalyzeGraph(protected val analysisContext: AnalysisContext, private rootsSet.clear() // Assert that any postponed objects have been handled - assert(cleanerObjects.isEmpty) + assert(cleanerObjects.isEmpty()) assert(softReferenceIdToParentMap.isEmpty()) assert(weakReferenceIdToParentMap.isEmpty()) @@ -557,8 +559,9 @@ open class AnalyzeGraph(protected val analysisContext: AnalysisContext, private val childrenStackSizes = listProvider.createIntList("dominatorBuf3", (objectCount + 2).toLong()) var csEntries = 0 var poEdgeCount = rootsSet.size - for (id in rootsSet) { - childrenStack[csEntries++] = id + val iterator = rootsSet.iterator() + while (iterator.hasNext()) { + childrenStack[csEntries++] = iterator.nextInt() } childrenStackSizes[0] = csEntries @@ -581,8 +584,8 @@ open class AnalyzeGraph(protected val analysisContext: AnalysisContext, private nav.copyReferencesTo(refList) var refsAdded = 0 for (i in 0 until refList.size) { - if (refList[i] != 0L) { - childrenStack[csEntries++] = refList[i].toInt() + if (refList.getLong(i) != 0L) { + childrenStack[csEntries++] = refList.getLong(i).toInt() refsAdded++ poEdgeCount++ } @@ -648,8 +651,8 @@ open class AnalyzeGraph(protected val analysisContext: AnalysisContext, private } outgoingCardListOffsets[i] = ncardrefs for (j in 0 until references.size) { - if (references[j] != 0L) { - val target = postorderNumbers[references[j].toInt()] + if (references.getLong(j) != 0L) { + val target = postorderNumbers[references.getLong(j).toInt()] edgeListOffsets[target]++ outgoingCardRefs[ncardrefs++] = target shr cardBits } @@ -699,8 +702,8 @@ open class AnalyzeGraph(protected val analysisContext: AnalysisContext, private addEdge(i, rootPonum) } for (j in 0 until references.size) { - if (references[j] != 0L) { - val target = postorderNumbers[references[j].toInt()] + if (references.getLong(j) != 0L) { + val target = postorderNumbers[references.getLong(j).toInt()] addEdge(target, i) } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java index c099ac301d2c..9703a34e0bb3 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/VfsUtilPerformanceTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.vfs; import com.intellij.concurrency.JobLauncher; @@ -12,7 +12,9 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.io.IoTestUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.ex.temp.TempFileSystem; -import com.intellij.openapi.vfs.newvfs.*; +import com.intellij.openapi.vfs.newvfs.ManagingFS; +import com.intellij.openapi.vfs.newvfs.NewVirtualFile; +import com.intellij.openapi.vfs.newvfs.RefreshQueue; import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent; import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; @@ -25,7 +27,7 @@ import com.intellij.util.ExceptionUtil; import com.intellij.util.ThrowableRunnable; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; -import it.unimi.dsi.fastutil.ints.IntSortedSets; +import it.unimi.dsi.fastutil.ints.IntSets; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; @@ -326,7 +328,7 @@ public class VfsUtilPerformanceTest extends BareTestFixtureTestCase { events.add(new VFileCreateEvent(this, temp, childName, false, null, null, null)); } List names = ContainerUtil.map(events, e -> ((VFileCreateEvent)e).getChildName()); - temp.removeChildren(IntSortedSets.EMPTY_SET, names); + temp.removeChildren(IntSets.emptySet(), names); } private void eventsForDeleting(List events, VirtualDirectoryImpl temp) { diff --git a/platform/util/src/com/intellij/openapi/util/text/TrigramBuilder.java b/platform/util/src/com/intellij/openapi/util/text/TrigramBuilder.java index 0767c3f8cbfc..ea566e447eb6 100644 --- a/platform/util/src/com/intellij/openapi/util/text/TrigramBuilder.java +++ b/platform/util/src/com/intellij/openapi/util/text/TrigramBuilder.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.util.text; import com.intellij.util.text.CharArrayUtil; @@ -12,7 +12,6 @@ import org.jetbrains.annotations.NotNull; import java.util.Map; import java.util.NoSuchElementException; import java.util.function.BiConsumer; -import java.util.function.Consumer; import java.util.function.IntPredicate; public final class TrigramBuilder { @@ -31,7 +30,7 @@ public final class TrigramBuilder { if (!consumer.consumeTrigramsCount(trigrams.size())) { return false; } - IntIterator iterator = trigrams.intIterator(); + IntIterator iterator = trigrams.iterator(); while (iterator.hasNext()) { int trigram = iterator.nextInt(); if (!consumer.test(trigram)) { @@ -62,7 +61,7 @@ public final class TrigramBuilder { @Override public void forEach(BiConsumer consumer) { - trigrams.forEach((Consumer)integer -> { + trigrams.forEach(integer -> { consumer.accept(integer, null); }); } @@ -72,7 +71,7 @@ public final class TrigramBuilder { return new AbstractObjectSet>() { @Override public ObjectIterator> iterator() { - IntIterator iterator = trigrams.intIterator(); + IntIterator iterator = trigrams.iterator(); return new AbstractObjectIterator>() { @Override public boolean hasNext() { diff --git a/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java b/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java index 7f5488dc2cc3..f9ea4e622e78 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java +++ b/platform/util/src/com/intellij/util/indexing/impl/FileId2ValueMapping.java @@ -1,10 +1,10 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.indexing.impl; import com.intellij.util.SmartList; -import it.unimi.dsi.fastutil.Pair; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectIntImmutablePair; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -16,19 +16,19 @@ final class FileId2ValueMapping { FileId2ValueMapping(@NotNull ValueContainerImpl valueContainer) { this.valueContainer = valueContainer; - List> cleanupDeletions = new SmartList<>(); + List> cleanupDeletions = new SmartList<>(); valueContainer.forEach((id, value) -> { Value previousValue = associateFileIdToValueSkippingContainer(id, value); if (previousValue != null) { - cleanupDeletions.add(Pair.of(previousValue, id)); + cleanupDeletions.add(ObjectIntImmutablePair.of(previousValue, id)); //ValueContainerImpl.LOG.error("Duplicated value for id = " + id + " in " + valueContainer.getDebugMessage()); } return true; }); - for (Pair deletion : cleanupDeletions) { - valueContainer.removeValue(deletion.second(), ValueContainerImpl.unwrap(deletion.first())); + for (ObjectIntImmutablePair deletion : cleanupDeletions) { + valueContainer.removeValue(deletion.rightInt(), ValueContainerImpl.unwrap(deletion.left())); } } diff --git a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java index 4c3fa9557d18..70aa7c065e61 100644 --- a/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java +++ b/platform/util/src/com/intellij/util/indexing/impl/ValueContainerImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.indexing.impl; import com.intellij.openapi.diagnostic.Logger; @@ -12,7 +12,6 @@ import com.intellij.util.io.DataExternalizer; import com.intellij.util.io.DataInputOutputUtil; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -21,10 +20,7 @@ import org.jetbrains.annotations.Nullable; import java.io.DataInputStream; import java.io.DataOutput; import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; +import java.util.*; import java.util.function.IntPredicate; @ApiStatus.Internal @@ -242,8 +238,9 @@ public class ValueContainerImpl extends UpdatableValueContainer im //noinspection unchecked return (InvertedIndexValueIterator)EmptyValueIterator.INSTANCE; } - Map mapping = ObjectUtils.notNull(asMapping(), - Object2ObjectMaps.singleton(wrapValue(asValue()), myInputIdMappingValue)); + + Map value = asMapping(); + Map mapping = value == null ? Collections.singletonMap(wrapValue(asValue()), myInputIdMappingValue) : value; return new InvertedIndexValueIterator() { private Value current; private Object currentValue; diff --git a/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByPagedStorageLockFree.java b/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByPagedStorageLockFree.java index 9aa5cf5a88b5..8b2f2e767b8a 100644 --- a/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByPagedStorageLockFree.java +++ b/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByPagedStorageLockFree.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.io.keyStorage; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; @@ -8,7 +8,6 @@ import com.intellij.util.io.*; import com.intellij.util.io.pagecache.Page; import com.intellij.util.io.pagecache.PagedStorage; import com.intellij.util.io.pagecache.PagedStorageWithPageUnalignedAccess; -import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -372,7 +371,7 @@ public final class AppendableStorageBackedByPagedStorageLockFree implement } public @NotNull AppendMemoryBuffer copy() { - return new AppendMemoryBuffer(ByteArrays.copy(buffer), bufferPosition, startingOffsetInFile); + return new AppendMemoryBuffer(buffer.clone(), bufferPosition, startingOffsetInFile); } public @NotNull AppendMemoryBuffer rewind(int offsetInFile) { diff --git a/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByResizableMappedFile.java b/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByResizableMappedFile.java index e3ffb66a7858..cbc84f52d79f 100644 --- a/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByResizableMappedFile.java +++ b/platform/util/src/com/intellij/util/io/keyStorage/AppendableStorageBackedByResizableMappedFile.java @@ -1,11 +1,10 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.io.keyStorage; import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream; import com.intellij.util.ExceptionUtil; import com.intellij.util.io.DataOutputStream; import com.intellij.util.io.*; -import it.unimi.dsi.fastutil.bytes.ByteArrays; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -363,7 +362,7 @@ public final class AppendableStorageBackedByResizableMappedFile implements } public synchronized @NotNull AppendMemoryBuffer copy() { - return new AppendMemoryBuffer(ByteArrays.copy(buffer), bufferPosition, startingOffsetInFile); + return new AppendMemoryBuffer(buffer.clone(), bufferPosition, startingOffsetInFile); } public synchronized @NotNull AppendMemoryBuffer rewind(int offsetInFile) { diff --git a/platform/util/src/com/intellij/util/io/pagecache/impl/PagesTable.java b/platform/util/src/com/intellij/util/io/pagecache/impl/PagesTable.java index f00c6d503db7..137951d56b82 100644 --- a/platform/util/src/com/intellij/util/io/pagecache/impl/PagesTable.java +++ b/platform/util/src/com/intellij/util/io/pagecache/impl/PagesTable.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.io.pagecache.impl; import com.intellij.openapi.util.IntRef; @@ -347,7 +347,8 @@ public final class PagesTable { @VisibleForTesting public Int2IntMap collectProbeLengthsHistogram() { - final Int2IntMap histo = new Int2IntOpenHashMap(); + @SuppressWarnings("SSBasedInspection") + Int2IntOpenHashMap histo = new Int2IntOpenHashMap(); for (int i = 0; i < pages.length(); i++) { final PageImpl page = pages.get(i); if (page != null) { diff --git a/platform/util/src/com/intellij/util/keyFMap/MapBackedFMap.java b/platform/util/src/com/intellij/util/keyFMap/MapBackedFMap.java index ba06eab7fbc5..b4e7083db716 100644 --- a/platform/util/src/com/intellij/util/keyFMap/MapBackedFMap.java +++ b/platform/util/src/com/intellij/util/keyFMap/MapBackedFMap.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.util.keyFMap; import com.intellij.openapi.util.Key; @@ -13,13 +13,15 @@ final class MapBackedFMap extends Int2ObjectOpenHashMap implements KeyFM private MapBackedFMap(@NotNull MapBackedFMap oldMap, final int keyToExclude) { super(oldMap.size()); - oldMap.int2ObjectEntrySet().fastForEach(entry -> { + ObjectIterator> iterator = oldMap.int2ObjectEntrySet().fastIterator(); + while (iterator.hasNext()) { + Entry entry = iterator.next(); int key = entry.getIntKey(); if (key != keyToExclude) { put(key, entry.getValue()); } assert key >= 0 : key; - }); + } assert size() > ArrayBackedFMap.ARRAY_THRESHOLD; } diff --git a/platform/util/ui/src/com/intellij/ui/scale/Scale.kt b/platform/util/ui/src/com/intellij/ui/scale/Scale.kt index aaa3d21cb12a..f5e22ba73b07 100644 --- a/platform/util/ui/src/com/intellij/ui/scale/Scale.kt +++ b/platform/util/ui/src/com/intellij/ui/scale/Scale.kt @@ -1,11 +1,10 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. @file:Suppress("ReplaceGetOrSet", "ReplacePutWithAssignment") package com.intellij.ui.scale import com.intellij.ui.JreHiDpiUtil import com.intellij.ui.scale.ScaleType.* -import it.unimi.dsi.fastutil.doubles.Double2ObjectMap import it.unimi.dsi.fastutil.doubles.Double2ObjectOpenHashMap import it.unimi.dsi.fastutil.longs.Long2ObjectFunction import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap @@ -13,7 +12,6 @@ import org.jetbrains.annotations.ApiStatus.Internal import java.util.* import java.util.function.DoubleFunction - /** * The IDE supports two different HiDPI modes: * @@ -50,12 +48,12 @@ enum class ScaleType { * Currently, it's derived from the UI font size, specified in the IDE Settings. * * The user scale value depends on which HiDPI mode is enabled. - * In the IDE-managed HiDPI mode the user scale "includes" the default system scale and simply equals it with the default UI font size. - * In the JRE-managed HiDPI mode the user scale is independent of the system scale and equals 1.0 with the default UI font size. + * In the IDE-managed HiDPI mode, the user scale "includes" the default system scale and simply equals it with the default UI font size. + * In the JRE-managed HiDPI mode, the user scale is independent of the system scale and equals 1.0 with the default UI font size. * In case the default UI font size changes, the user scale changes proportionally in both the HiDPI modes. * - * In the IDE-managed HiDPI mode the user scale completely defines the UI scale. - * In the JRE-managed HiDPI mode the user scale can be considered a supplementary scale taking effect in cases like + * In the IDE-managed HiDPI mode, the user scale completely defines the UI scale. + * In the JRE-managed HiDPI mode, the user scale can be considered a supplementary scale, taking effect in cases like * the IDE Presentation Mode and when the default UI scale is changed by the user. * * @see JBUIScale.setUserScaleFactor @@ -66,7 +64,7 @@ enum class ScaleType { /** * The system scale factor is defined by the device DPI and/or the system settings. * For instance, a Mac Retina monitor device has the system scale 2.0 by default. - * As there can be multiple devices (multi-monitor configuration) there can be multiple system scale factors, appropriately. + * As there can be multiple devices (multi-monitor configuration), there can be multiple system scale factors, appropriately. * However, there's always a single default system scale factor corresponding to the default device. * And it's the only system scale available in the IDE-managed HiDPI mode. * @@ -87,7 +85,7 @@ enum class ScaleType { @Internal fun of(value: Float): Scale { return simpleCache.get().computeIfAbsent(cacheKey(value = value, type = this), Long2ObjectFunction { key -> - Scale(value = Float.fromBits((key shr 32).toInt()).toDouble(), type = ScaleType.values()[key.toInt()]) + Scale(value = Float.fromBits((key shr 32).toInt()).toDouble(), type = entries[key.toInt()]) }) } } @@ -102,7 +100,7 @@ data class Scale(@JvmField val value: Double, @JvmField val type: ScaleType) // the cache radically reduces potential thousands of equal Scale instances private val cache = ThreadLocal.withInitial { - EnumMap>(ScaleType::class.java) + EnumMap>(ScaleType::class.java) } private fun cacheKey(value: Float, type: ScaleType): Long { diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/PermanentGraphImpl.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/PermanentGraphImpl.java index b6de65657690..172311b28bec 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/PermanentGraphImpl.java +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/PermanentGraphImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.vcs.log.graph.impl.facade; @@ -19,10 +19,7 @@ import com.intellij.vcs.log.graph.impl.permanent.*; import com.intellij.vcs.log.graph.impl.print.GraphColorGetterByHeadFactory; import com.intellij.vcs.log.graph.linearBek.LinearBekController; import com.intellij.vcs.log.graph.utils.LinearGraphUtils; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.ints.IntSet; +import it.unimi.dsi.fastutil.ints.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -206,7 +203,7 @@ public final class PermanentGraphImpl implements PermanentGraph permanentCommitsInfo = PermanentCommitsInfoImpl.newInstance(graphCommits, idsGenerator.getNotLoadedCommits()); - GraphLayoutImpl permanentGraphLayout = GraphLayoutBuilder.build(linearGraph, (nodeIndex1, nodeIndex2) -> { + GraphLayoutImpl permanentGraphLayout = GraphLayoutBuilder.build(linearGraph, (IntComparator)(nodeIndex1, nodeIndex2) -> { CommitId commitId1 = permanentCommitsInfo.getCommitId(nodeIndex1); CommitId commitId2 = permanentCommitsInfo.getCommitId(nodeIndex2); return headCommitsComparator.compare(commitId1, commitId2); diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/DfsUtil.kt b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/DfsUtil.kt index f1a7cecf8a28..2fed766dc377 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/DfsUtil.kt +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/utils/DfsUtil.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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. - */ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.vcs.log.graph.utils @@ -31,7 +17,7 @@ object Dfs { private fun walk(start: Int, stack: IntArrayList, nextNodeFun: (Int) -> Int) { stack.push(start) - while (!stack.isEmpty) { + while (!stack.isEmpty()) { val nextNode = nextNodeFun(stack.topInt()) if (nextNode == Dfs.NextNode.EXIT) return if (nextNode != Dfs.NextNode.NODE_NOT_FOUND) { diff --git a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongMultiMap.kt b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongMultiMap.kt index 06c210f5d3e3..80c976aab155 100644 --- a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongMultiMap.kt +++ b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongMultiMap.kt @@ -1,4 +1,6 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +@file:Suppress("ReplaceGetOrSet") + package com.intellij.platform.workspace.storage.impl.containers import com.intellij.util.containers.CollectionFactory @@ -17,7 +19,7 @@ internal class BidirectionalLongMultiMap { constructor() { keyToValues = Long2ObjectOpenHashMap() - valueToKeys = CollectionFactory.createSmallMemoryFootprintMap() + valueToKeys = HashMap() } private constructor( @@ -40,8 +42,7 @@ internal class BidirectionalLongMultiMap { fun containsValue(value: V): Boolean = valueToKeys.containsKey(value) fun put(key: Long, value: V): Boolean { - val keys: Any? = valueToKeys[value] - when (keys) { + when (val keys = valueToKeys.get(value)) { null -> { valueToKeys[value] = key } @@ -56,7 +57,7 @@ internal class BidirectionalLongMultiMap { if (values == null) { @Suppress("SSBasedInspection") values = ObjectOpenHashSet() - keyToValues[key] = values + keyToValues.put(key, values) } return values.add(value) } @@ -64,8 +65,7 @@ internal class BidirectionalLongMultiMap { fun removeKey(key: Long): Boolean { val values = keyToValues[key] ?: return false for (v in values) { - val keys: Any = valueToKeys[v]!! - when (keys) { + when (val keys = valueToKeys.get(v)!!) { is LongOpenHashSet -> { keys.remove(key) if (keys.isEmpty()) { diff --git a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongSetMap.kt b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongSetMap.kt index 5b72f1a8b2e8..86942fced657 100644 --- a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongSetMap.kt +++ b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/containers/BidirectionalLongSetMap.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.platform.workspace.storage.impl.containers import it.unimi.dsi.fastutil.longs.Long2ObjectMap @@ -65,7 +65,7 @@ internal class BidirectionalLongSetMap private constructor( fun removeValue(v: V) { val ks: LongOpenHashSet? = valueToKeysMap.remove(v) if (ks != null) { - val longIterator = ks.longIterator() + val longIterator = ks.iterator() while (longIterator.hasNext()) { val k = longIterator.nextLong() keyToValueMap.remove(k) diff --git a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/trace/ReadTraceIndex.kt b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/trace/ReadTraceIndex.kt index ed3d11f752e5..afe72f13b832 100644 --- a/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/trace/ReadTraceIndex.kt +++ b/platform/workspace/storage/src/com/intellij/platform/workspace/storage/impl/trace/ReadTraceIndex.kt @@ -32,7 +32,7 @@ internal class ReadTraceIndex private constructor( fun set(traces: ReadTraceHashSet, obj: T) { val existingTraces = objToTrace.remove(obj) if (existingTraces != null) { - val existingTracesIterator = existingTraces.longIterator() + val existingTracesIterator = existingTraces.iterator() while (existingTracesIterator.hasNext()) { val trace = existingTracesIterator.nextLong() val objs = traceToObj.get(trace) @@ -45,7 +45,7 @@ internal class ReadTraceIndex private constructor( } } - val tracesIterator = traces.longIterator() + val tracesIterator = traces.iterator() while (tracesIterator.hasNext()) { val trace = tracesIterator.nextLong() if (existingTraces == null || trace !in existingTraces) {