Skip to content

Commit

Permalink
Compositor // Fix update(updateExisting: true).
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Feb 18, 2025
1 parent 08db711 commit ed3357e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/Megrez/1_Compositor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,14 @@ extension Megrez {
@discardableResult
public func update(updateExisting: Bool = false) -> Int {
let maxSpanLength = maxSpanLength
let rangeOfPositions = max(0, cursor - maxSpanLength) ..< min(
cursor + maxSpanLength,
keys.count
)
let rangeOfPositions: Range<Int>
if updateExisting {
rangeOfPositions = 0 ..< spans.count
} else {
let lowerbound = Swift.max(0, cursor - maxSpanLength)
let upperbound = Swift.min(cursor + maxSpanLength, keys.count)
rangeOfPositions = lowerbound ..< upperbound
}
var nodesChanged = 0
rangeOfPositions.forEach { position in
let rangeOfLengths = 1 ... min(maxSpanLength, rangeOfPositions.upperBound - position)
Expand Down

0 comments on commit ed3357e

Please sign in to comment.