Skip to content

Commit 2d383ab

Browse files
slissonmhuster23
authored andcommitted
chore(bulk-model-sync-lib): set INodeResolutionScope for the whole import
Setting the scope for each reference resolution creates some unnecessary overhead, because we use the same scope during the entire import. Setting it at the beginning of the import is sufficient.
1 parent 8ceb819 commit 2d383ab

File tree

1 file changed

+27
-27
lines changed
  • bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk

1 file changed

+27
-27
lines changed

bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/ModelImporter.kt

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,36 @@ class ModelImporter(private val root: INode, private val continueOnError: Boolea
7070
*/
7171
@JvmName("importData")
7272
fun import(data: ModelData) {
73-
logImportSize(data.root, logger)
74-
logger.info { "Building indices for import..." }
75-
originalIdToExisting.clear()
76-
postponedReferences.clear()
77-
nodesToRemove.clear()
78-
numExpectedNodes = countExpectedNodes(data.root)
79-
currentNodeProgress = 0
80-
buildExistingIndex(root)
81-
82-
logger.info { "Importing nodes..." }
83-
data.root.originalId()?.let { originalIdToExisting[it] = root }
84-
syncNode(root, data.root)
85-
86-
logger.info { "Synchronizing references..." }
87-
postponedReferences.forEach {
88-
doAndPotentiallyContinueOnErrors {
89-
it.invoke()
73+
INodeResolutionScope.runWithAdditionalScope(root.getArea()) {
74+
logImportSize(data.root, logger)
75+
logger.info { "Building indices for import..." }
76+
originalIdToExisting.clear()
77+
postponedReferences.clear()
78+
nodesToRemove.clear()
79+
numExpectedNodes = countExpectedNodes(data.root)
80+
currentNodeProgress = 0
81+
buildExistingIndex(root)
82+
83+
logger.info { "Importing nodes..." }
84+
data.root.originalId()?.let { originalIdToExisting[it] = root }
85+
syncNode(root, data.root)
86+
87+
logger.info { "Synchronizing references..." }
88+
postponedReferences.forEach {
89+
doAndPotentiallyContinueOnErrors {
90+
it.invoke()
91+
}
9092
}
91-
}
9293

93-
logger.info { "Removing extra nodes..." }
94-
nodesToRemove.forEach {
95-
doAndPotentiallyContinueOnErrors {
96-
it.remove()
94+
logger.info { "Removing extra nodes..." }
95+
nodesToRemove.forEach {
96+
doAndPotentiallyContinueOnErrors {
97+
it.remove()
98+
}
9799
}
98-
}
99100

100-
logger.info { "Synchronization finished." }
101+
logger.info { "Synchronization finished." }
102+
}
101103
}
102104

103105
private fun countExpectedNodes(data: NodeData): Int =
@@ -110,9 +112,7 @@ class ModelImporter(private val root: INode, private val continueOnError: Boolea
110112
doAndPotentiallyContinueOnErrors {
111113
syncProperties(node, data)
112114
syncChildren(node, data)
113-
INodeResolutionScope.runWithAdditionalScope(node.getArea()) {
114-
syncReferences(node, data)
115-
}
115+
syncReferences(node, data)
116116
}
117117
}
118118

0 commit comments

Comments
 (0)