libcollections: Fix RingBuf growth for non-power-of-two capacities#16314
libcollections: Fix RingBuf growth for non-power-of-two capacities#16314bors merged 1 commit intorust-lang:masterfrom
Conversation
|
I don't see what the bug was. It was requesting to reserve a particular size, which means the vec will definitely reserve at least that much, so it looks like the worst that should have happened was that excess capacity was wasted. What was actually happening to cause a bug? Extending the ringbuf to whatever capacity the vector decided to create seems like it could affect the ringbuf algorithm in subtle ways. Does the ringbuf care about growing in exact sizes of two? |
If it guarantees that it is always a power of two, it can be more efficient by using shifts/bitmasking instead of divisions/remainders for computing the wrapped-around indexes (etc.). |
|
@brson The RingBuf itself doesn't seem to care about power of two currently, but it was making assumptions about the growth of the underlying vector which lead to indexing being wrong. E.g. |
|
@huonw It doesn't seem to be doing that. I don't see any power-of-two assumptions in the code. |
|
@brson The rest of the |
|
@brson yes, it's not currently doing that, it was merely a related possible optimisation. |
…r=Veykril
`macro_rules` as macro name
This PR makes RA parse `macro_rules! {}` (note the missing identifier) as a `MACRO_CALL` instead of `MACRO_RULES`.
Fixes rust-lang#15969.
Extremely small change, -0.018% performance improvement on `tokio` Just some warmup for continuing on larger optimizations (i.e. `nonminimal_bool`) changelog:Remove allocations via String pre-allocating.
See test for details.