about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2018-05-16 20:59:27 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2018-05-17 09:34:20 +1000
commitf778bdefdd9663aa78c31ffc7773e31bcae4fb39 (patch)
treeffa3ff5d6f360749f1753c0d7e8b56b79432d5fb /src/rustllvm/RustWrapper.cpp
parent6fc409ed0938cd2f501642abcaa675977fa5035a (diff)
downloadrust-f778bdefdd9663aa78c31ffc7773e31bcae4fb39.tar.gz
rust-f778bdefdd9663aa78c31ffc7773e31bcae4fb39.zip
Avoid repeated HashMap lookups in `opt_normalize_projection_type`.
There is a hot path through `opt_normalize_projection_type`:
- `try_start` does a cache lookup (#1).
- The result is a `NormalizedTy`.
- There are no unresolved type vars, so we call `complete`.
- `complete` does *another* cache lookup (#2), then calls
  `SnapshotMap::insert`.
- `insert` does *another* cache lookup (#3), inserting the same value
  that's already in the cache.

This patch optimizes this hot path by introducing `complete_normalized`,
for use when the value is known in advance to be a `NormalizedTy`. It
always avoids lookup #2. Furthermore, if the `NormalizedTy`'s
obligations are empty (the common case), we know that lookup #3 would be
a no-op, so we avoid it, while inserting a Noop into the `SnapshotMap`'s
undo log.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions