Skip to content

Commit

Permalink
performance improvement for update project
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-coding committed Sep 10, 2024
1 parent 4d95fee commit bb12f96
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/main/kotlin/gropius/service/architecture/LayoutService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ class LayoutService(
layout: Layout, input: UpdateLayoutInput, batchUpdater: NodeBatchUpdater,
) {
val cache = batchUpdater.cache
val newLayouts = input.relationPartnerLayouts.orElse(emptyList())
if (newLayouts.isEmpty()) {
return
}
val relationPartnerLayouts =
layout.relationPartnerLayouts(cache).associateBy { it.relationPartner(cache).value.rawId!! }
input.relationPartnerLayouts.orElse(emptyList()).forEach {
newLayouts.forEach {
if (it.layout != null) {
val existingLayout = relationPartnerLayouts[it.relationPartner.value]
if (existingLayout == null) {
Expand Down Expand Up @@ -80,8 +84,12 @@ class LayoutService(
layout: Layout, input: UpdateLayoutInput, batchUpdater: NodeBatchUpdater,
) {
val cache = batchUpdater.cache
val newLayouts = input.relationLayouts.orElse(emptyList())
if (newLayouts.isEmpty()) {
return
}
val relationLayouts = layout.relationLayouts(cache).associateBy { it.relation(cache).value.rawId!! }
input.relationLayouts.orElse(emptyList()).forEach {
newLayouts.forEach {
if (it.layout != null) {
val existingLayout = relationLayouts[it.relation.value]
val xCoordinates = it.layout.points.map { point -> point.x }.toIntArray()
Expand Down

0 comments on commit bb12f96

Please sign in to comment.