Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,27 +1,15 @@
function lcs_greedy(x,y){
var symbols = {},
r=0,p=0,p1,L=0,idx,
m=x.length,n=y.length,
S = new Buffer(m<n?n:m);
p1 = popsym(0);
for(i=0;i < m;i++){
p = (r===p)?p1:popsym(i);
p1 = popsym(i+1);
idx=(p > p1)?(i++,p1):p;
if(idx===n){p=popsym(i);}
else{
r=idx;
S[L++]=x.charCodeAt(i);
var t=i;
while(i>-1&&j>-1){
switch(c[i][j]){
default:i--,j--;
continue;
case (i&&c[i-1][j]):
if(t!==i){lcs.unshift(x.substring(i+1,t+1));}
t=--i;
continue;
case (j&&c[i][j-1]): j--;
if(t!==i){lcs.unshift(x.substring(i+1,t+1));}
t=i;
}
}
return S.toString('utf8',0,L);
function popsym(index){
var s = x[index],
pos = symbols[s]+1;
pos = y.indexOf(s,pos>r?pos:r);
if(pos===-1){pos=n;}
symbols[s]=pos;
return pos;
}
}
if(t!==i){lcs.unshift(x.substring(i+1,t+1));}