Replace the trove4j collections usages with the fastutil ones

The trove4j library is licensed under LGPL, and that causes some troubles while working with it. The fastutil library provides the same functionality in the context of our needs, and is licensed under the Apache license.
^KTI-1135 In Progress
This commit is contained in:
Alexander.Likhachev
2023-12-06 12:48:36 +01:00
committed by Space Team
parent dd5fffebf2
commit 21b438f55d
27 changed files with 71 additions and 86 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ plugins {
dependencies {
api(project(":core:descriptors"))
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
}
sourceSets {
@@ -4,7 +4,7 @@
package org.jetbrains.kotlin.js.backend;
import gnu.trove.THashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.util.Collections;
import java.util.Set;
@@ -142,7 +142,7 @@ public class JsReservedIdentifiers {
"$stack", "$stackDepth", "$location",
};
reservedGlobalSymbols = new THashSet<String>(commonBuiltins.length);
reservedGlobalSymbols = new ObjectOpenHashSet<>(commonBuiltins.length);
Collections.addAll(reservedGlobalSymbols, commonBuiltins);
}
@@ -4,6 +4,7 @@
package org.jetbrains.kotlin.js.backend;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import kotlin.text.StringsKt;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.js.backend.ast.*;
@@ -12,7 +13,6 @@ import org.jetbrains.kotlin.js.backend.ast.JsIntLiteral;
import org.jetbrains.kotlin.js.backend.ast.JsVars.JsVar;
import org.jetbrains.kotlin.js.common.IdentifierPolicyKt;
import org.jetbrains.kotlin.js.util.TextOutput;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -190,7 +190,7 @@ public class JsToStringGenerationVisitor extends JsVisitor {
* because the statements designated by statementEnds and statementStarts are
* those that appear directly within these global blocks.
*/
private Set<JsBlock> globalBlocks = new THashSet<JsBlock>();
private Set<JsBlock> globalBlocks = new ObjectOpenHashSet<>();
@NotNull
protected final TextOutput p;
+1 -1
View File
@@ -8,7 +8,7 @@ dependencies {
compileOnly(project(":js:js.parser")) // TODO remove, required for JSON AST
compileOnly(project(":js:js.frontend")) // TODO remove
compileOnly(intellijCore())
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
}
sourceSets {
@@ -4,7 +4,7 @@
*/
package org.jetbrains.kotlin.js.sourceMap
import gnu.trove.TObjectIntHashMap
import com.intellij.util.containers.ObjectIntHashMap
import org.jetbrains.kotlin.js.parser.sourcemaps.*
import java.io.File
import java.io.IOException
@@ -17,13 +17,6 @@ class SourceMap3Builder(
private val pathPrefix: String
) : SourceMapBuilder {
private class ObjectIntHashMap<T> : TObjectIntHashMap<T>() {
override fun get(key: T): Int {
val index = index(key)
return if (index < 0) -1 else _values[index]
}
}
private val out = StringBuilder(8192)
private val sources = ObjectIntHashMap<SourceKey>()
@@ -98,7 +91,7 @@ class SourceMap3Builder(
private fun getSourceIndex(source: String, fileIdentity: Any?, contentSupplier: Supplier<Reader?>): Int {
val key = SourceKey(source, fileIdentity)
var sourceIndex = sources[key]
var sourceIndex = sources.get(key)
if (sourceIndex == -1) {
sourceIndex = orderedSources.size
sources.put(key, sourceIndex)
@@ -109,7 +102,7 @@ class SourceMap3Builder(
}
private fun getNameIndex(name: String): Int {
var nameIndex = names[name]
var nameIndex = names.get(name)
if (nameIndex == -1) {
nameIndex = orderedNames.size
names.put(name, nameIndex)