src/or/consdiff.c
static int
optimal_column_to_split(smartlist_slice_t *top, smartlist_slice_t *bot,
                        smartlist_slice_t *slice2)
{
  int *lens_top = lcs_lengths(top, slice2, 1);
  int *lens_bot = lcs_lengths(bot, slice2, -1);
  int column=0, max_sum=-1;

  for (int i = 0; i < slice2->len+1; ++i) {
    int sum = lens_top[i] + lens_bot[slice2->len-i];
    if (sum > max_sum) {
      column = i;
      max_sum = sum;
    }
  }
  tor_free(lens_top);
  tor_free(lens_bot);

  return column;
}
/*
 * Helper: Given that slice1 has been split by half into top and bot, we want
 * to fetch the column at which to split slice2 so that we are still on track
 * to the optimal diff solution, i.e. the shortest one. We use lcs_lengths
 * since the shortest diff is just another way to say the longest common
 * subsequence.
 */
Given that slice1 has been split by half into top and bot, we want
to fetch the column at which to split slice2 so that we are still on track
to the optimal diff solution, i.e. the shortest one. We use lcs_lengths
since the shortest diff is just another way to say the longest common
subsequence.
Given that slice1 has been split by half into top and bot we want to fetch the column at which to split slice2 so that we are still on track to the optimal diff solution i . e . the shortest one . We use lcs_lengths since the shortest diff is just another way to say the longest common subsequence .
static int
optimal_column_to_split(smartlist_slice_t *top, smartlist_slice_t *bot,
                        smartlist_slice_t *slice2)
{
  int *lens_top = lcs_lengths(top, slice2, 1);
  int *lens_bot = lcs_lengths(bot, slice2, -1);
  int column=0, max_sum=-1;
  for (int i = 0; i < slice2->len+1; ++i) {
    int sum = lens_top[i] + lens_bot[slice2->len-i];
    if (sum > max_sum) {
      column = i;
      max_sum = sum;
    }
  }
  tor_free(lens_top);
  tor_free(lens_bot);
  return column;
}
static int optimal_column_to_split ( smartlist_slice_t * top , smartlist_slice_t * bot , smartlist_slice_t * slice2 ) { int * lens_top = lcs_lengths ( top , slice2 , 1 ) ; int * lens_bot = lcs_lengths ( bot , slice2 , -1 ) ; int column = 0 , max_sum = -1 ; for ( int i = 0 ; i < slice2 -> len + 1 ; ++ i ) { int sum = lens_top [ i ] + lens_bot [ slice2 -> len - i ] ; if ( sum > max_sum ) { column = i ; max_sum = sum ; } } tor_free ( lens_top ) ; tor_free ( lens_bot ) ; return column ; }
Helper: Given that slice1 has been split by half into top and bot, we want
 to fetch the column at which to split slice2 so that we are still on track
 to the optimal diff solution, i.e.
Helper : Given that slice1 has been split by half into top and bot we want to fetch the column at which to split slice2 so that we are still on track to the optimal diff solution i . e .