Uh oh!
There was an error while loading. Please reload this page.
Simplify hash table drops - #40739
Conversation
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
commented
Mar 22, 2017
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
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). |
arthurprs
left a comment
There was a problem hiding this comment.
There's no tangible benefit but I'd settle for a net loss of LOC 👍
alexcrichton
commented
Mar 23, 2017
@bors: r=arthurprs delegate=arthurprs |
bors
commented
Mar 23, 2017
✌️ @arthurprs can now approve this pull request |
bors
commented
Mar 23, 2017
📌 Commit a033f1a has been approved by |
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.
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.
This replaces the
std::collections::hash::table::RevMoveBucketsiterator with a simpler
whileloop. This iterator was only used fordropping the remaining elements of a
RawTable, so instead we can justloop 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.