コード例 #1
0
ファイル: DiffEngine.cs プロジェクト: knyazkov-ma/knyazkov
 private void GetLongestSourceMatch(DiffState curItem, int destIndex,int destEnd, int sourceStart,int sourceEnd)
 {
     int maxDestLength = (destEnd - destIndex) + 1;
     int curLength = 0;
     int curBestLength = 0;
     int curBestIndex = -1;
     int maxLength = 0;
     for (int sourceIndex = sourceStart; sourceIndex <= sourceEnd; sourceIndex++)
     {
         maxLength = Math.Min(maxDestLength,(sourceEnd - sourceIndex) + 1);
         if (maxLength <= curBestLength)
         {
             //No chance to find a longer one any more
             break;
         }
         curLength = GetSourceMatchLength(destIndex,sourceIndex,maxLength);
         if (curLength > curBestLength)
         {
             //This is the best match so far
             curBestIndex = sourceIndex;
             curBestLength = curLength;
         }
         //jump over the match
         sourceIndex += curBestLength;
     }
     //DiffState cur = _stateList.GetByIndex(destIndex);
     if (curBestIndex == -1)
     {
         curItem.SetNoMatch();
     }
     else
     {
         curItem.SetMatch(curBestIndex, curBestLength);
     }
 }
コード例 #2
0
ファイル: Structures.cs プロジェクト: knyazkov-ma/knyazkov
 public DiffState GetByIndex(int index)
 {
     DiffState retval = _array[index];
     if (retval == null)
     {
         retval = new DiffState();
         _array[index] = retval;
     }
     return retval;
 }