[Workspace Model][IJPL-161667] Replace put with putIsAbsent in ImmutableEntityStorageImpl.initializeEntity

It does not make sense to replace a value in `entityCache`
if it was concurrently inserted by someone else.

GitOrigin-RevId: f28ff2357ced479942bef3c05483d5106a757d34
This commit is contained in:
Roman Golyshev
2024-09-05 20:48:09 +02:00
committed by intellij-monorepo-bot
parent e517d0e1e8
commit eefc6bb21f

View File

@@ -95,9 +95,10 @@ internal open class ImmutableEntityStorageImpl(
}
val newData = newInstance()
entityCache.put(entityId, newData)
val inserted = entityCache.putIfAbsent(entityId, newData) ?: newData
return newData
@Suppress("UNCHECKED_CAST")
return inserted as T
}
companion object {