* Diff two screens with identical width. * Dispatches each row to a small, JIT-friendly function.
( prev: Screen, next: Screen, startX: number, endX: number, startY: number, endY: number, cb: DiffCallback, )
| 1303 | * Dispatches each row to a small, JIT-friendly function. |
| 1304 | */ |
| 1305 | function diffSameWidth( |
| 1306 | prev: Screen, |
| 1307 | next: Screen, |
| 1308 | startX: number, |
| 1309 | endX: number, |
| 1310 | startY: number, |
| 1311 | endY: number, |
| 1312 | cb: DiffCallback, |
| 1313 | ): boolean { |
| 1314 | const prevCells = prev.cells |
| 1315 | const nextCells = next.cells |
| 1316 | const width = prev.width |
| 1317 | const prevHeight = prev.height |
| 1318 | const nextHeight = next.height |
| 1319 | const stride = width << 1 |
| 1320 | |
| 1321 | const prevCell: Cell = { |
| 1322 | char: ' ', |
| 1323 | styleId: 0, |
| 1324 | width: CellWidth.Narrow, |
| 1325 | hyperlink: undefined, |
| 1326 | } |
| 1327 | const nextCell: Cell = { |
| 1328 | char: ' ', |
| 1329 | styleId: 0, |
| 1330 | width: CellWidth.Narrow, |
| 1331 | hyperlink: undefined, |
| 1332 | } |
| 1333 | |
| 1334 | const rowEndX = Math.min(endX, width) |
| 1335 | let rowCI = (startY * width + startX) << 1 |
| 1336 | |
| 1337 | for (let y = startY; y < endY; y++) { |
| 1338 | const prevIn = y < prevHeight |
| 1339 | const nextIn = y < nextHeight |
| 1340 | |
| 1341 | if (prevIn && nextIn) { |
| 1342 | if ( |
| 1343 | diffRowBoth( |
| 1344 | prevCells, |
| 1345 | nextCells, |
| 1346 | prev, |
| 1347 | next, |
| 1348 | rowCI, |
| 1349 | y, |
| 1350 | startX, |
| 1351 | rowEndX, |
| 1352 | prevCell, |
| 1353 | nextCell, |
| 1354 | cb, |
| 1355 | ) |
| 1356 | ) |
| 1357 | return true |
| 1358 | } else if (prevIn) { |
| 1359 | if (diffRowRemoved(prev, rowCI, y, startX, rowEndX, prevCell, cb)) |
| 1360 | return true |
| 1361 | } else if (nextIn) { |
| 1362 | if ( |
no test coverage detected