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

Remove unused loop (3) #191

Merged
merged 1 commit into from May 9, 2024
Merged

Remove unused loop (3) #191

merged 1 commit into from May 9, 2024

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Apr 30, 2024

The nested loop is only executed once, so made the code much more readable and clearer by removing it.

Also, cleaned up the rest of the SetCost function

missing_symbol_sum = missing_symbol_sum.wrapping_add(1);
for i in 0..histogram_size {
if histogram[i] == 0 {
sum = sum.wrapping_add(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you keep the variable named "missing_symbol_sum"...it's confusing to a reader why we might compute the log2sum of a "partial" sum... if it's called as a different variable then the logic makes sense.

if you want to make it clearer you could reduce the scope of "sum" above to a nested block and then have missing_symbol_sum be defined outside the block (and assigned in it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx, fixed

The nested loop is only executed once, so made the code much more readable and clearer by removing it.

Also, cleaned up the rest of the SetCost function
@danielrh danielrh merged commit 0fd919c into dropbox:master May 9, 2024
2 checks passed
@nyurik nyurik deleted the simpler-loop3 branch May 9, 2024 07:22
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.

None yet

2 participants