diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-10-04 14:29:20 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-10-04 17:03:41 +1000 |
| commit | 5515a976464e488949a6a7324ac41ecaf3246a19 (patch) | |
| tree | 417375b4bc76f3ae824c02e9d069f5ede0741122 /src/libstd/sys/unix/stack_overflow.rs | |
| parent | a69e0e0ab402591e9e42c596054ea45df702f3e0 (diff) | |
| download | rust-5515a976464e488949a6a7324ac41ecaf3246a19.tar.gz rust-5515a976464e488949a6a7324ac41ecaf3246a19.zip | |
Introduce a special case in `IntRange::from_const`.
The `if let Some(val) = value.try_eval_bits(...)` branch in `from_const()` is very hot for the `unicode_normalization` benchmark. This commit introduces a special-case alternative for scalars that avoids `try_eval_bits()` and all the functions it calls (`Const::eval()`, `ConstValue::try_to_bits()`, `ConstValue::try_to_scalar()`, and `Scalar::to_bits()`), instead extracting the result immediately. The type and value checking done by `Scalar::to_bits()` is replicated by moving it into a new function `Scalar::check_raw()` and using that new function in the special case. PR #64673 introduced some special-case handling of scalar types in `Const::try_eval_bits()`. This handling is now moved out of that function into the new `IntRange::integral_size_and_signed_bias` function. This commit reduces the instruction count for `unicode_normalization-check-clean` by about 10%.
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
