diff options
author | Charles Blake <cblake@csail.mit.edu> | 2015-02-07 09:37:17 -0500 |
---|---|---|
committer | Charles Blake <cblake@csail.mit.edu> | 2015-02-07 09:37:17 -0500 |
commit | 42f8f1cd1fe491c19362a4b03f89952ea6e160bc (patch) | |
tree | 2db3cbcd2a6c6abdde85e34aa75241eab4a69765 /.gitignore | |
parent | 8e685585a6a650d14f81bef5fbdfae10ac60a33a (diff) | |
download | Nim-42f8f1cd1fe491c19362a4b03f89952ea6e160bc.tar.gz |
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.)
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions