Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for the possibility of duplicate hashes and names #128

Merged
merged 10 commits into from
Jan 25, 2024

Conversation

cccs-rs
Copy link
Contributor

@cccs-rs cccs-rs commented Jan 19, 2024

No description provided.

nn_map.setdefault(x["name"], []).append(x["sha256"])
)
for x in new
]
Copy link
Contributor

Choose a reason for hiding this comment

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

defaultdict(list) should be used instead of repeating .setdefault(... everywhere.

nn_map.setdefault(x["name"], []).append(x["sha256"])
)
for x in new
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any advantage to using a list comprehension for operations that modify in place over a for loop?

)
for x in new
]

oh_map = {x["sha256"]: x["name"] for x in original}
on_map = {x["name"]: x["sha256"] for x in original}
nh_map = {x["sha256"]: x["name"] for x in new}
Copy link
Contributor

Choose a reason for hiding this comment

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

oh_map, on_map, nh_map, and nn_map are overwritten here, so the list comprehensions don't have any effect. These 4 lines should be removed

@cccs-rs cccs-rs requested a review from cccs-jh January 25, 2024 17:37

# Prune out items in the lists where nothing changed
for file in list(original):
if file in original and file in new:
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to check that file in original. Because file is iterating over a copy original it must be. There is no chance that it is removed from original previously since .remove only removes the first equal item, so if there are two copies of the same file the second will still be in original.

@cccs-rs cccs-rs merged commit 6696abe into main Jan 25, 2024
1 check passed
@cccs-rs cccs-rs deleted the bugfix/duplicate_name_hashes branch January 25, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants