Project

General

Profile

Actions

Task #3820

closed

Refactor Fib::removeOldNextHopsFromFibEntryAndNfd() for simplicity, readability.

Added by Nicholas Gordon over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
10/19/2016
Due date:
06/09/2017
% Done:

0%

Estimated time:

Description

As it stands, the context that this method lives in makes it hard to understand what it does. A summary of what it does:

  1. Fetches the NextHop list of the entry passed to it.
  2. Iterate over that list, comparing that element to every element in the argument list.
  3. If no match is found, remove the current element from the list and purge it from the FIB and NFD.
  4. Advance one element of the current list and go to step 2.

This is a fine way of doing this, but I think needlessly complex, and it makes the code very hard to read:

    addNextHopsToFibEntryAndNfd(entry, hopsToAdd);

    removeOldNextHopsFromFibEntryAndNfd(entry, hopsToAdd);

The first method call implies that you are adding the hopsToAdd to entry, but the second method call implies just the opposite. The first method adds hops in hopsToAdd, and the second removes hops not in hopsToAdd.

So, there are two things to do:

  1. Refactor the method name and stub to be more readable.
  2. Refactor the code logic to use something more efficient and readable (say, set difference of the two lists?).
Actions #1

Updated by Nicholas Gordon almost 7 years ago

  • Due date set to 06/09/2017
  • Target version set to v0.4.0
Actions #2

Updated by Laqin Fan almost 7 years ago

  • Status changed from New to Code review
Actions #3

Updated by Laqin Fan over 6 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF