MCPcopy Create free account
hub / github.com/denoland/std / snake

Function snake

internal/diff.ts:274–294  ·  view source on GitHub ↗
(
    k: number,
    A: T[],
    B: T[],
    slide?: FarthestPoint,
    down?: FarthestPoint,
  )

Source from the content-addressed store, hash-verified

272 let ptr = 0;
273
274 function snake<T>(
275 k: number,
276 A: T[],
277 B: T[],
278 slide?: FarthestPoint,
279 down?: FarthestPoint,
280 ): FarthestPoint {
281 const M = A.length;
282 const N = B.length;
283 const fp = createFp(k, M, routes, diffTypesPtrOffset, ptr, slide, down);
284 ptr = fp.id;
285 while (fp.y + k < M && fp.y < N && A[fp.y + k] === B[fp.y]) {
286 const prev = fp.id;
287 ptr++;
288 fp.id = ptr;
289 fp.y += 1;
290 routes[ptr] = prev;
291 routes[ptr + diffTypesPtrOffset] = COMMON;
292 }
293 return fp;
294 }
295
296 let currentFp = fp[delta + offset];
297 assertFp(currentFp);

Callers 1

diffFunction · 0.85

Calls 1

createFpFunction · 0.85

Tested by

no test coverage detected