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

Simplify hash table drops #40739

Merged
merged 1 commit into from
Mar 25, 2017
Merged

Simplify hash table drops #40739

merged 1 commit into from
Mar 25, 2017

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Mar 22, 2017

This replaces the std::collections::hash::table::RevMoveBuckets
iterator with a simpler while loop. This iterator was only used for
dropping the remaining elements of a RawTable, so instead we can just
loop through directly and drop them in place.

This should be functionally equivalent to the former code, but a little
easier to read. I was hoping it might have some performance benefit
too, but it seems the optimizer was already good enough to see through
the iterator -- the generated code is nearly the same. Maybe it will
still help if an element type has more complicated drop code.

This replaces the `std::collections::hash::table::RevMoveBuckets`
iterator with a simpler `while` loop.  This iterator was only used for
dropping the remaining elements of a `RawTable`, so instead we can just
loop through directly and drop them in place.

This should be functionally equivalent to the former code, but a little
easier to read.  I was hoping it might have some performance benefit
too, but it seems the optimizer was already good enough to see through
the iterator -- the generated code is nearly the same.  Maybe it will
still help if an element type has more complicated drop code.
@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@leonardo-m
Copy link

leonardo-m commented Mar 22, 2017

I was hoping it might have some performance benefit too, but

Even if you don't see performance improvements, replacing iterators with while/for loops often reduces compilation time. You can see this very well in iterator-heavy code, that compiles much slower than equivalent code made of for/while loops (and probably the amount of RAM used to compile the code is different, the iterators-based code uses lot of types).

Copy link
Contributor

@arthurprs arthurprs left a comment

Choose a reason for hiding this comment

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

There's no tangible benefit but I'd settle for a net loss of LOC 👍

@alexcrichton
Copy link
Member

@bors: r=arthurprs delegate=arthurprs

@bors
Copy link
Contributor

bors commented Mar 23, 2017

✌️ @arthurprs can now approve this pull request

@bors
Copy link
Contributor

bors commented Mar 23, 2017

📌 Commit a033f1a has been approved by arthurprs

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 24, 2017
Simplify hash table drops

This replaces the `std::collections::hash::table::RevMoveBuckets`
iterator with a simpler `while` loop.  This iterator was only used for
dropping the remaining elements of a `RawTable`, so instead we can just
loop through directly and drop them in place.

This should be functionally equivalent to the former code, but a little
easier to read.  I was hoping it might have some performance benefit
too, but it seems the optimizer was already good enough to see through
the iterator -- the generated code is nearly the same.  Maybe it will
still help if an element type has more complicated drop code.
bors added a commit that referenced this pull request Mar 24, 2017
Rollup of 5 pull requests

- Successful merges: #40501, #40524, #40636, #40739, #40756
- Failed merges:
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 24, 2017
Simplify hash table drops

This replaces the `std::collections::hash::table::RevMoveBuckets`
iterator with a simpler `while` loop.  This iterator was only used for
dropping the remaining elements of a `RawTable`, so instead we can just
loop through directly and drop them in place.

This should be functionally equivalent to the former code, but a little
easier to read.  I was hoping it might have some performance benefit
too, but it seems the optimizer was already good enough to see through
the iterator -- the generated code is nearly the same.  Maybe it will
still help if an element type has more complicated drop code.
bors added a commit that referenced this pull request Mar 24, 2017
Rollup of 8 pull requests

- Successful merges: #40567, #40602, #40636, #40739, #40756, #40790, #40794, #40803
- Failed merges:
@bors bors merged commit a033f1a into rust-lang:master Mar 25, 2017
@cuviper cuviper deleted the hash-rev-drop branch September 26, 2017 06:39
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.

7 participants