about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-04-02 00:40:38 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-04-02 00:40:38 +0530
commitabd747cd153c1ef3648831916017fb692200387d (patch)
tree4bdf5661fc617f76443b4c56b78199674b5d6d60 /src/liballoc
parent1d17e6eb1e181ef37cbb2d2df05bc84db7e4be8f (diff)
parent240734c31e529557583a0dc8e97abf858b4a375d (diff)
downloadrust-abd747cd153c1ef3648831916017fb692200387d.tar.gz
rust-abd747cd153c1ef3648831916017fb692200387d.zip
Rollup merge of #23847 - bcoopers:read_clarification, r=sfackler
This introduces no functional changes except for reducing a few unnecessary operations and variables.  Vec has the behavior that, if you request space past the capacity with reserve(), it will round up to the nearest power of 2.  What that effectively means is that after the first call to reserve(16), we are doubling our capacity every time.  So using the DEFAULT_BUF_SIZE and doubling cap_size() here is meaningless and has no effect on the call to reserve().

Note that with #23842 implemented this will hopefully have a clearer API and less of a need for commenting.  If #23842 is not implemented then the most clear implementation would be to call reserve_exact(buf.capacity()) at every step (and making sure that buf.capacity() is not zero at the beginning of the function of course).

Edit- functional change now introduced.  We will now zero 16 bytes of the vector first, then double to 32, then 64, etc. until we read 64kB.  This stops us from zeroing the entire vector when we double it, some of which may be wasted work.  Reallocation still follows the doubling strategy, but the responsibility has been moved to vec.extend(), which calls reserve() and push_back().
Diffstat (limited to 'src/liballoc')
0 files changed, 0 insertions, 0 deletions