@@ -28,27 +28,6 @@ extension StyledRangeContainer {
2828 // Ordered by priority, lower = higher priority.
2929 var allRuns = _storage. sorted ( by: { $0. key < $1. key } ) . map { $0. value. runs ( in: range. intRange) }
3030
31- #if DEBUG
32- // ASSERTION: Verify input contract - runs should be in positional order
33- for (priority, runs) in allRuns. enumerated ( ) {
34- var expectedStart = range. location
35- for (runIndex, run) in runs. enumerated ( ) {
36- assert ( run. length > 0 , " Run \( runIndex) in priority \( priority) has non-positive length: \( run. length) " )
37- }
38- // Note: Can't easily verify positional order without knowing absolute positions
39- // This would require the RangeStore to provide position info
40- }
41-
42- // ASSERTION: Verify total length consistency
43- let originalTotalLengths = allRuns. map { runs in runs. reduce ( 0 ) { $0 + $1. length } }
44- for (priority, totalLength) in originalTotalLengths. enumerated ( ) {
45- assert (
46- totalLength == range. length,
47- " Priority \( priority) total length ( \( totalLength) ) doesn't match expected length ( \( range. length) ) "
48- )
49- }
50- #endif
51-
5231 var runs : [ RangeStoreRun < StyleElement > ] = [ ]
5332 var minValue = allRuns. compactMap { $0. last } . enumerated ( ) . min ( by: { $0. 1 . length < $1. 1 . length } )
5433 var counter = 0
@@ -58,15 +37,9 @@ extension StyledRangeContainer {
5837 let minRunIdx = value. offset
5938 var minRun = value. element
6039
61- assert ( minRun. length > 0 , " Minimum run has non-positive length: \( minRun. length) " )
62-
6340 for idx in ( 0 ..< allRuns. count) . reversed ( ) where idx != minRunIdx {
6441 guard let last = allRuns [ idx] . last else { continue }
6542
66- assert (
67- last. length >= minRun. length,
68- " Run at priority \( idx) length ( \( last. length) ) is less than minimum length ( \( minRun. length) ) "
69- )
7043 if idx < minRunIdx {
7144 combineHigherPriority ( & minRun, last)
7245 } else {
@@ -85,27 +58,13 @@ extension StyledRangeContainer {
8558 allRuns [ minRunIdx] . removeLast ( )
8659 }
8760
61+ assert ( minRun. length > 0 , " Empty or negative runs are not allowed. " )
8862 runs. append ( minRun)
8963 minValue = allRuns. compactMap { $0. last } . enumerated ( ) . min ( by: { $0. 1 . length < $1. 1 . length } )
9064
91- debugRunState ( allRuns, step: counter)
9265 counter += 1
9366 }
9467
95- assert ( runs. allSatisfy ( { $0. length > 0 } ) , " Empty or negative lengths are not allowed " )
96-
9768 return runs. reversed ( )
9869 }
99-
100- #if DEBUG
101- private func debugRunState( _ allRuns: [ [ RangeStoreRun < StyleElement > ] ] , step: Int ) {
102- print ( " === Debug Step \( step) === " )
103- for (priority, runs) in allRuns. enumerated ( ) {
104- let lengths = runs. map { $0. length }
105- let totalLength = lengths. reduce ( 0 , + )
106- print ( " Priority \( priority) : lengths= \( lengths) , total= \( totalLength) " )
107- }
108- print ( )
109- }
110- #endif
11170}
0 commit comments