diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-11-20 11:06:45 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2018-12-12 10:36:15 +1100 |
| commit | 2bfe32cc9301d404c98d896efbabe8f04361d5bf (patch) | |
| tree | 667bba60d155cb2d2eca50df9e66165f34be7735 /src/libstd/sys/unix/stack_overflow.rs | |
| parent | f13006182c9df451e7703307467fc1717239cf6e (diff) | |
| download | rust-2bfe32cc9301d404c98d896efbabe8f04361d5bf.tar.gz rust-2bfe32cc9301d404c98d896efbabe8f04361d5bf.zip | |
Avoid regenerating the `Vec<PathBuf>` in `FileSearch::search()`.
`FileSearch::search()` traverses one or more directories. For each directory it generates a `Vec<PathBuf>` containing one element per file in that directory. In some benchmarks this occurs enough that the allocations done for the `PathBuf`s are significant, and in practice a small number of directories are being traversed over and over again. For example, when compiling the `tokio-webpush-simple` benchmark, two directories are traversed 58 times each. Each of these directories have more than 100 files. This commit changes things so that all the `Vec<PathBuf>`s that will be needed by a `Session` are precomputed when that `Session` is created; they are stored in `SearchPath`. `FileSearch` gets a reference to the necessary `SearchPath`s. This reduces instruction counts on several benchmarks by 1--5%. The commit also removes the barely-used `visited_dirs` hash in `for_each_lib_searchPath`. It only detects if `tlib_path` is the same as one of the previously seen paths, which is unlikely.
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
