Actions
Task #3820
closedRefactor Fib::removeOldNextHopsFromFibEntryAndNfd() for simplicity, readability.
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:
- Fetches the NextHop list of the entry passed to it.
- Iterate over that list, comparing that element to every element in the argument list.
- If no match is found, remove the current element from the list and purge it from the FIB and NFD.
- 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:
- Refactor the method name and stub to be more readable.
- Refactor the code logic to use something more efficient and readable (say, set difference of the two lists?).
Actions