about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2019-10-04 14:29:20 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2019-10-04 17:03:41 +1000
commit5515a976464e488949a6a7324ac41ecaf3246a19 (patch)
tree417375b4bc76f3ae824c02e9d069f5ede0741122 /src/libstd/sys/unix/stack_overflow.rs
parenta69e0e0ab402591e9e42c596054ea45df702f3e0 (diff)
downloadrust-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