Coverage Report

Created: 2025-09-07 07:00

/rust/registry/src/index.crates.io-6f17d22bba15001f/ryu-1.0.20/src/pretty/mantissa.rs
Line
Count
Source
1
use crate::digit_table::DIGIT_TABLE;
2
use core::ptr;
3
4
#[cfg_attr(feature = "no-panic", inline)]
5
1.08k
pub unsafe fn write_mantissa_long(mut output: u64, mut result: *mut u8) {
6
1.08k
    if (output >> 32) != 0 {
7
500
        // One expensive 64-bit division.
8
500
        let mut output2 = (output - 100_000_000 * (output / 100_000_000)) as u32;
9
500
        output /= 100_000_000;
10
500
11
500
        let c = output2 % 10_000;
12
500
        output2 /= 10_000;
13
500
        let d = output2 % 10_000;
14
500
        let c0 = (c % 100) << 1;
15
500
        let c1 = (c / 100) << 1;
16
500
        let d0 = (d % 100) << 1;
17
500
        let d1 = (d / 100) << 1;
18
500
        ptr::copy_nonoverlapping(
19
500
            DIGIT_TABLE.as_ptr().offset(c0 as isize),
20
500
            result.offset(-2),
21
500
            2,
22
500
        );
23
500
        ptr::copy_nonoverlapping(
24
500
            DIGIT_TABLE.as_ptr().offset(c1 as isize),
25
500
            result.offset(-4),
26
500
            2,
27
500
        );
28
500
        ptr::copy_nonoverlapping(
29
500
            DIGIT_TABLE.as_ptr().offset(d0 as isize),
30
500
            result.offset(-6),
31
500
            2,
32
500
        );
33
500
        ptr::copy_nonoverlapping(
34
500
            DIGIT_TABLE.as_ptr().offset(d1 as isize),
35
500
            result.offset(-8),
36
500
            2,
37
500
        );
38
500
        result = result.offset(-8);
39
581
    }
40
1.08k
    write_mantissa(output as u32, result);
41
1.08k
}
42
43
#[cfg_attr(feature = "no-panic", inline)]
44
1.08k
pub unsafe fn write_mantissa(mut output: u32, mut result: *mut u8) {
45
1.91k
    while output >= 10_000 {
46
836
        let c = output - 10_000 * (output / 10_000);
47
836
        output /= 10_000;
48
836
        let c0 = (c % 100) << 1;
49
836
        let c1 = (c / 100) << 1;
50
836
        ptr::copy_nonoverlapping(
51
836
            DIGIT_TABLE.as_ptr().offset(c0 as isize),
52
836
            result.offset(-2),
53
836
            2,
54
836
        );
55
836
        ptr::copy_nonoverlapping(
56
836
            DIGIT_TABLE.as_ptr().offset(c1 as isize),
57
836
            result.offset(-4),
58
836
            2,
59
836
        );
60
836
        result = result.offset(-4);
61
836
    }
62
1.08k
    if output >= 100 {
63
529
        let c = (output % 100) << 1;
64
529
        output /= 100;
65
529
        ptr::copy_nonoverlapping(
66
529
            DIGIT_TABLE.as_ptr().offset(c as isize),
67
529
            result.offset(-2),
68
529
            2,
69
529
        );
70
529
        result = result.offset(-2);
71
552
    }
72
1.08k
    if output >= 10 {
73
576
        let c = output << 1;
74
576
        ptr::copy_nonoverlapping(
75
576
            DIGIT_TABLE.as_ptr().offset(c as isize),
76
576
            result.offset(-2),
77
576
            2,
78
576
        );
79
576
    } else {
80
505
        *result.offset(-1) = b'0' + output as u8;
81
505
    }
82
1.08k
}