pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:601:    string a2="",b2="";    int a1, b1;    sscanf(a0,"%d.%s",a1,a2);    sscanf(b0,"%d.%s",b1,b2);    if (a1>b1) return 1;    if (a1<b1) return 0;    if (a2==b2) return 0;    return oid_sort_func(a2,b2);   }    - static array(array) low_chunky_diff(array d1, array d2) + static array(array) low_greedy_diff(array d1, array d2)   {    array r1, r2, x, y, yb, b, c;    r1 = r2 = ({});    int at, last, seen;    while(-1 != (at = search(d1, ({}), last)))    {    last = at + 1;    if(at < 2) continue;    b = d2[at-1]; yb = d2[at];   out:if(sizeof(yb) > sizeof(b))
pike.git/lib/modules/Array.pmod:642:    seen = at + 5;    }    }    if(!seen)    return ({ d1, d2 }); // No change.    return ({ r1 + d1[seen..], r2 + d2[seen..] });   }      //! Like @[Array.diff], but tries to generate bigger continuous chunks of the   //! differences, instead of maximizing the number of difference chunks. More - //! specifically, @[chunky_diff] optimizes the cases where @[Array.diff] returns + //! specifically, @[greedy_diff] optimizes the cases where @[Array.diff] returns   //! @code{({ ..., A, Z, B, ({}), C, ... })@}   //! @code{({ ..., A, X, B, Y+B, C, ... })@}   //! into the somewhat shorter diff arrays   //! @code{({ ..., A, Z, B+C, ... })@}   //! @code{({ ..., A, X+B+Y, B+C, ... })@} - array(array) chunky_diff(array from, array to) + array(array) greedy_diff(array from, array to)   {    array d1, d2;    [d1, d2] = Array.diff(from, to); -  [d2, d1] = low_chunky_diff(d2, d1); -  return low_chunky_diff(d1, d2); +  [d2, d1] = low_greedy_diff(d2, d1); +  return low_greedy_diff(d1, d2);   }