@@ -464,7 +464,7 @@ private static bool HistogramCombineStochastic(Vp8LHistogramSet histograms, int
464464 }
465465 }
466466
467- HistoListUpdateHead ( histoPriorityList , p ) ;
467+ HistoListUpdateHead ( histoPriorityList , p , j ) ;
468468 j ++ ;
469469 }
470470
@@ -524,7 +524,7 @@ private static void HistogramCombineGreedy(Vp8LHistogramSet histograms)
524524 }
525525 else
526526 {
527- HistoListUpdateHead ( histoPriorityList , p ) ;
527+ HistoListUpdateHead ( histoPriorityList , p , i ) ;
528528 i ++ ;
529529 }
530530 }
@@ -646,7 +646,7 @@ private static double HistoPriorityListPush(
646646
647647 histoList . Add ( pair ) ;
648648
649- HistoListUpdateHead ( histoList , pair ) ;
649+ HistoListUpdateHead ( histoList , pair , histoList . Count - 1 ) ;
650650
651651 return pair . CostDiff ;
652652 }
@@ -673,13 +673,11 @@ private static void HistoListUpdatePair(
673673 /// <summary>
674674 /// Check whether a pair in the list should be updated as head or not.
675675 /// </summary>
676- private static void HistoListUpdateHead ( List < HistogramPair > histoList , HistogramPair pair )
676+ private static void HistoListUpdateHead ( List < HistogramPair > histoList , HistogramPair pair , int idx )
677677 {
678678 if ( pair . CostDiff < histoList [ 0 ] . CostDiff )
679679 {
680- // Replace the best pair.
681- int oldIdx = histoList . IndexOf ( pair ) ;
682- histoList [ oldIdx ] = histoList [ 0 ] ;
680+ histoList [ idx ] = histoList [ 0 ] ;
683681 histoList [ 0 ] = pair ;
684682 }
685683 }
0 commit comments