nl_tokens: Calculates prices of long rep and long rep + literal + rep0 .
pl_tokens: private int calcLongRepPrices ( int pos , int posState , int avail , int anyRepPrice ) { int startLen = MATCH_LEN_MIN ; int lenLimit = Math . <mask> ( avail , niceLen ) ; for ( int rep = 0 ; rep < REPS ; ++ rep ) { int len = lz . getMatchLen ( opts [ optCur ] . reps [ rep ] , lenLimit ) ; if ( len < MATCH_LEN_MIN ) continue ; while ( optEnd < optCur + len ) opts [ ++ optEnd ] . reset ( ) ; int longRepPrice = getLongRepPrice ( anyRepPrice , rep , opts [ optCur ] . state , posState ) ; for ( int i = len ; i >= MATCH_LEN_MIN ; -- i ) { int price = longRepPrice + repLenEncoder . getPrice ( i , posState ) ; if ( price < opts [ optCur + i ] . price ) opts [ optCur + i ] . set1 ( price , optCur , rep ) ; } if ( rep == 0 ) startLen = len + 1 ; int len2Limit = Math . min ( niceLen , avail - len - 1 ) ; int len2 = lz . getMatchLen ( len + 1 , opts [ optCur ] . reps [ rep ] , len2Limit ) ; if ( len2 >= MATCH_LEN_MIN ) { // Rep int price = longRepPrice + repLenEncoder . getPrice ( len , posState ) ; nextState . set ( opts [ optCur ] . state ) ; nextState . updateLongRep ( ) ; // Literal int curByte = lz . getByte ( len , 0 ) ; int matchByte = lz . getByte ( 0 ) ; // lz.getByte(len, len) int prevByte = lz . getByte ( len , 1 ) ; price += literalEncoder . getPrice ( curByte , matchByte , prevByte , pos + len , nextState ) ; nextState . updateLiteral ( ) ; // Rep0 int nextPosState = ( pos + len + 1 ) & posMask ; price += getLongRepAndLenPrice ( 0 , len2 , nextState , nextPosState ) ; int i = optCur + len + 1 + len2 ; while ( optEnd < i ) opts [ ++ optEnd ] . reset ( ) ; if ( price < opts [ i ] . price ) opts [ i ] . set3 ( price , optCur , rep , len , 0 ) ; } } return startLen ; }