Skip to content

Comments

Removing unused and unnecessary code#5309

Merged
radoering merged 5 commits intopython-poetry:masterfrom
dimbleby:reachable-nonsense
Mar 18, 2022
Merged

Removing unused and unnecessary code#5309
radoering merged 5 commits intopython-poetry:masterfrom
dimbleby:reachable-nonsense

Conversation

@dimbleby
Copy link
Contributor

Pull Request Check List

A follow-up to my remark in #5305 that seen looked redundant on the node in the solver's depth first search, because the surrounding search already had a visited.

The doubt in my mind was that there was a second caller of reachable(), here, and I hadn't taken the time to figure out the effect on that call site.

On reflection it is clear that the seen cache will be populated by the time we get to that second caller - which happens after the depth-first search has completed. As a result, that second reachable() never returns anything other than an empty list.

(I also confirmed this by asserting as much in the code, and verifying that the test suite still passed)

Since nothing seems to be broken by that list being empty, I've assumed that we don't need that second reachable() call after all; and then it is clear that seen is indeed redundant. So I've made two commits:

  • remove the code which was made useless by seen
  • remove seen

(I probably have given myself a small merge conflict with #5305, happy to sort that out if and when the first of these is merged).

@dimbleby dimbleby force-pushed the reachable-nonsense branch from fc99b89 to 7c499e2 Compare March 13, 2022 14:26
@dimbleby dimbleby force-pushed the reachable-nonsense branch from 7c499e2 to 4cf4f0c Compare March 13, 2022 14:55
@dimbleby
Copy link
Contributor Author

(I have rearranged this and #5305 so that this one contains the refactoring and the other contains only the fix)

@dimbleby dimbleby mentioned this pull request Mar 13, 2022
2 tasks
Copy link
Member

@radoering radoering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch and well prepared. At some points, I had to think twice about it, but in the end I am quite sure you are absolutely right. 👍

@radoering radoering merged commit ad2bfe7 into python-poetry:master Mar 18, 2022
@dimbleby dimbleby deleted the reachable-nonsense branch March 18, 2022 17:24
@kasteph kasteph mentioned this pull request May 30, 2022
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants