From ddd28d2cfda1843bfea04f30335c1272d0265db2 Mon Sep 17 00:00:00 2001 From: Artem Khvastunov Date: Fri, 6 Jul 2018 18:15:32 +0200 Subject: [PATCH] avoid storing values in memory when IndexGenerator.CHECK_HASH_COLLISIONS is on --- .../src/org/jetbrains/index/IndexGenerator.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/index-tools/src/org/jetbrains/index/IndexGenerator.kt b/tools/index-tools/src/org/jetbrains/index/IndexGenerator.kt index 0c6d3a611373..269ed080f212 100644 --- a/tools/index-tools/src/org/jetbrains/index/IndexGenerator.kt +++ b/tools/index-tools/src/org/jetbrains/index/IndexGenerator.kt @@ -38,7 +38,7 @@ abstract class IndexGenerator(private val indexStorageFilePath: String) { println("Writing indices to ${storage.baseFile.absolutePath}") storage.use { - val map = HashMap>() + val map = HashMap() for (file in roots) { println("Processing files in root ${file.path}") @@ -57,7 +57,7 @@ abstract class IndexGenerator(private val indexStorageFilePath: String) { private fun indexFile(file: VirtualFile, hashing: FileContentHashing, - map: HashMap>, + map: MutableMap, storage: PersistentHashMap, stats: Stats): Boolean { try { @@ -77,13 +77,12 @@ abstract class IndexGenerator(private val indexStorageFilePath: String) { stats.indexed.incrementAndGet() if (CHECK_HASH_COLLISIONS) { - map[hashCode] = Pair(fileContent.contentAsText.toString(), value) + map[hashCode] = fileContent.contentAsText.toString() } } else { - TestCase.assertEquals(item.first, - fileContent.contentAsText.toString()) - TestCase.assertTrue(value == item.second) + TestCase.assertEquals(item, fileContent.contentAsText.toString()) + TestCase.assertTrue(storage.get(hashCode) == value) } } else {