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 bradfitz/iter package dependency #474

Closed
wants to merge 1 commit into from
Closed

Remove bradfitz/iter package dependency #474

wants to merge 1 commit into from

Conversation

alexandear
Copy link

The package github.com/bradfitz/iter was intended to be an educational joke when it was released in 2014.
It's not idiomatic to use the package and it doesn't add any significant value to readability.

@@ -65,12 +64,12 @@ func BenchmarkPieceMarkComplete(b *testing.B, ci storage.ClientImpl, pieceSize i
}
// Fill the cache
if capacity > 0 {
for range iter.N(int((capacity + info.TotalLength() - 1) / info.TotalLength())) {
for i := 0; i < int((capacity + info.TotalLength() - 1) / info.TotalLength()); i++ {
Copy link
Owner

Choose a reason for hiding this comment

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

How do we know that TotalLength won't be recomputed on every iteration now?

@anacrolix
Copy link
Owner

I use bradfitz/iter (and have my own clone of it) somewhat to rail against Go's lack of expressiveness. I'm not convinced it's actually inferior to the alternative given that it is less error prone, probably guarantees intermediate caching of the bounds, and seems syntactically appropriate given how you would range over a builtin container type.

@alexandear alexandear closed this Mar 27, 2021
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