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
@@ -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)