[json] IJPL-166426 Cache root schema object's file url because it is accessed in the equals & hashcode methods frequently enough

(cherry picked from commit 3af3524fb8d7d044da4508090911d8bc97aeda83)

IJ-CR-149952

GitOrigin-RevId: e9b81f32abe75d1a48c5ece1c351d6ba209481ee
This commit is contained in:
Nikita Katkov
2024-11-14 15:54:08 +01:00
committed by intellij-monorepo-bot
parent c4e34440e7
commit 21c80c4fbc

View File

@@ -17,6 +17,7 @@ private val IDS_MAP_KEY = Key<Map<String, String>>("ids")
private val DYNAMIC_ANCHORS_MAP_KEY = Key<Map<String, String>>("dynamicAnchors")
private val INJECTIONS_MAP_KEY = Key<Boolean>("injections")
private val DEPRECATIONS_MAP_KEY = Key<Boolean>("deprecations")
private val FILE_URL_MAP_KEY = Key<String>("fileUrl")
@ApiStatus.Internal
class RootJsonSchemaObjectBackedByJackson(rootNode: JsonNode, val schemaFile: VirtualFile?)
@@ -57,7 +58,9 @@ class RootJsonSchemaObjectBackedByJackson(rootNode: JsonNode, val schemaFile: Vi
}
override fun getFileUrl(): String? {
return schemaFile?.url
return getOrComputeValue(FILE_URL_MAP_KEY) {
schemaFile?.url.orEmpty()
}.takeIf { it.isNotEmpty() }
}
override fun getRawFile(): VirtualFile? {