-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
nn_map.setdefault(x["name"], []).append(x["sha256"]) | ||
) | ||
for x in new | ||
] |
There was a problem hiding this comment.
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 | ||
] |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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
|
||
# Prune out items in the lists where nothing changed | ||
for file in list(original): | ||
if file in original and file in new: |
There was a problem hiding this comment.
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
.
No description provided.