Skip to content

Commit b81dab4

Browse files
committed
simplify line break wrappers
1 parent 9c00d73 commit b81dab4

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/line-break.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,11 @@ export function normalizeLineStart(
168168

169169
export function countPreparedLines(prepared: PreparedLineBreakData, maxWidth: number): number {
170170
if (prepared.simpleLineWalkFastPath) {
171-
return countPreparedLinesSimple(prepared, maxWidth)
171+
return walkPreparedLinesSimple(prepared, maxWidth)
172172
}
173173
return walkPreparedLines(prepared, maxWidth)
174174
}
175175

176-
function countPreparedLinesSimple(prepared: PreparedLineBreakData, maxWidth: number): number {
177-
return walkPreparedLinesSimple(prepared, maxWidth)
178-
}
179-
180176
function walkPreparedLinesSimple(
181177
prepared: PreparedLineBreakData,
182178
maxWidth: number,
@@ -250,10 +246,6 @@ function walkPreparedLinesSimple(
250246
lineEndGraphemeIndex = 0
251247
}
252248

253-
function appendBreakableSegment(segmentIndex: number): void {
254-
appendBreakableSegmentFrom(segmentIndex, 0)
255-
}
256-
257249
function appendBreakableSegmentFrom(segmentIndex: number, startGraphemeIndex: number): void {
258250
const gWidths = breakableWidths[segmentIndex]!
259251
const gPrefixWidths = breakablePrefixWidths[segmentIndex] ?? null
@@ -296,7 +288,7 @@ function walkPreparedLinesSimple(
296288

297289
if (!hasContent) {
298290
if (w > maxWidth && breakableWidths[i] !== null) {
299-
appendBreakableSegment(i)
291+
appendBreakableSegmentFrom(i, 0)
300292
} else {
301293
startLineAtSegment(i, w)
302294
}
@@ -331,7 +323,7 @@ function walkPreparedLinesSimple(
331323

332324
if (w > maxWidth && breakableWidths[i] !== null) {
333325
emitCurrentLine()
334-
appendBreakableSegment(i)
326+
appendBreakableSegmentFrom(i, 0)
335327
i++
336328
continue
337329
}
@@ -458,10 +450,6 @@ export function walkPreparedLines(
458450
pendingBreakKind = kind
459451
}
460452

461-
function appendBreakableSegment(segmentIndex: number): void {
462-
appendBreakableSegmentFrom(segmentIndex, 0)
463-
}
464-
465453
function appendBreakableSegmentFrom(segmentIndex: number, startGraphemeIndex: number): void {
466454
const gWidths = breakableWidths[segmentIndex]!
467455
const gPrefixWidths = breakablePrefixWidths[segmentIndex] ?? null
@@ -575,7 +563,7 @@ export function walkPreparedLines(
575563

576564
if (!hasContent) {
577565
if (w > maxWidth && breakableWidths[i] !== null) {
578-
appendBreakableSegment(i)
566+
appendBreakableSegmentFrom(i, 0)
579567
} else {
580568
startLineAtSegment(i, w)
581569
}
@@ -626,7 +614,7 @@ export function walkPreparedLines(
626614

627615
if (w > maxWidth && breakableWidths[i] !== null) {
628616
emitCurrentLine()
629-
appendBreakableSegment(i)
617+
appendBreakableSegmentFrom(i, 0)
630618
i++
631619
continue
632620
}

0 commit comments

Comments
 (0)