Nim/lib/pure/collections
Charles Blake 42f8f1cd1f Fix unnecessarily slow set building from openArray.
The estimation of the initialSize as simply array len + 10 was too small for
for all but the smallest sets.  It would not elide/skip one final enlarge().
That last one is actually always the most expensive enlarge().  Indeed, in a
series where one to start from tiny and build up the table..that last one is
about 50% of all the enlarging time in general.  So, this simple and reasonable
optimization (compared to just starting at 64) was only helping about half as
much as it could.

Introduce a rightSize() proc to be the inverse to mustRehash().  Export it
to clients since pre-sizing is externally useful in set construction and the
current mustRehash rules are opaque and beyond the control of clients.

Also add test module logic to check that rightSize() and mustRehash() are
inverses in the appropriate sense..not really in a block/assertion throwing
unit test since this is a peformance nice-to-have issue rather than about
basic correctness.  (Also, fix a too vs. two typo in doc comment.)
2015-02-07 09:37:17 -05:00
..
critbits.nim documented new C++ support 2015-01-28 12:59:04 +01:00
intsets.nim documented new C++ support 2015-01-28 12:59:04 +01:00
lists.nim Fix SinglyLinkedRing in lists module 2015-02-01 03:04:18 +01:00
LockFreeHash.nim Nimrod renamed to Nim 2014-08-28 09:59:26 +02:00
queues.nim Merge pull request #2020 from def-/mitems 2015-02-01 05:19:47 +05:00
rtarrays.nim Happy new year! 2015-01-06 15:26:33 +01:00
sequtils.nim Changed name 'pred' to 'op' in mapIt template 2015-02-02 14:42:00 +00:00
sets.nim Fix unnecessarily slow set building from openArray. 2015-02-07 09:37:17 -05:00
tables.nim documented new C++ support 2015-01-28 12:59:04 +01:00