diff options
| author | est31 <MTest31@outlook.com> | 2020-10-25 05:53:35 +0100 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2020-10-25 22:50:48 +0100 |
| commit | 6c9b8ada0c269fdbfd36cf66060bab9898824dd2 (patch) | |
| tree | 650ae8e3a19d851b51d9cee191e9083895328426 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | a21c2eb1213715b26ae61944cb5edea897d77ebd (diff) | |
| download | rust-6c9b8ada0c269fdbfd36cf66060bab9898824dd2.tar.gz rust-6c9b8ada0c269fdbfd36cf66060bab9898824dd2.zip | |
Precompute the associated items
The associated_items(def_id) call allocates internally. Previously, we'd have called it for each pair, so we'd have had O(n^2) many calls. By precomputing the associated items, we avoid repeating so many allocations. The only instance where this precomputation would be a regression is if there's only one inherent impl block for the type, as the inner loop then doesn't run. In that instance, we just early return. Also, use SmallVec to avoid doing an allocation at all if the number is small (the case for most impl blocks out there).
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
