about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform/coverage/graph.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-02 21:01:47 +0000
committerbors <bors@rust-lang.org>2021-03-02 21:01:47 +0000
commit35dbef235048f9a2939dc20effe083ca483c37ff (patch)
treef25520c8f6358a010f853af91f6c44acd3060915 /compiler/rustc_mir/src/transform/coverage/graph.rs
parent795a934b51cb481ea3cb1cc8c3835a043a9e0102 (diff)
parent8abc5fd3be35c39fdb93335acebf15dbbac180be (diff)
downloadrust-35dbef235048f9a2939dc20effe083ca483c37ff.tar.gz
rust-35dbef235048f9a2939dc20effe083ca483c37ff.zip
Auto merge of #82562 - llogiq:one-up-82248, r=oli-obk
Optimize counting digits in line numbers during error reporting further

This one-ups #82248 by switching the strategy: Instead of dividing the value by 10 repeatedly, we compare with a limit that we multiply by 10 repeatedly. In my benchmarks, this took between 50% and 25% of the original time. The reasons for being faster are:

1. While LLVM is able to replace a division by constant with a multiply + shift, a plain multiplication is still faster. However, this doesn't even factor, because
2. Multiplication, unlike division, is const. We also use a simple for-loop instead of a more complex loop + break, which allows
3. rustc to const-fold the whole loop, and indeed the assembly output simply shows a series of comparisons.
Diffstat (limited to 'compiler/rustc_mir/src/transform/coverage/graph.rs')
0 files changed, 0 insertions, 0 deletions