Sha256: fa914ec63b3f86cbdaf7933d7c44e1bc1f93c1239a29a5f86934680a7e957570

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

use crate::digit_table::DIGIT_TABLE;
use core::ptr;

#[cfg_attr(feature = "no-panic", inline)]
pub unsafe fn write_exponent3(mut k: isize, mut result: *mut u8) -> usize {
    let sign = k < 0;
    if sign {
        *result = b'-';
        result = result.offset(1);
        k = -k;
    }

    debug_assert!(k < 1000);
    if k >= 100 {
        *result = b'0' + (k / 100) as u8;
        k %= 100;
        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
        ptr::copy_nonoverlapping(d, result.offset(1), 2);
        sign as usize + 3
    } else if k >= 10 {
        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
        ptr::copy_nonoverlapping(d, result, 2);
        sign as usize + 2
    } else {
        *result = b'0' + k as u8;
        sign as usize + 1
    }
}

#[cfg_attr(feature = "no-panic", inline)]
pub unsafe fn write_exponent2(mut k: isize, mut result: *mut u8) -> usize {
    let sign = k < 0;
    if sign {
        *result = b'-';
        result = result.offset(1);
        k = -k;
    }

    debug_assert!(k < 100);
    if k >= 10 {
        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
        ptr::copy_nonoverlapping(d, result, 2);
        sign as usize + 2
    } else {
        *result = b'0' + k as u8;
        sign as usize + 1
    }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs
wasmtime-28.0.0 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs
wasmtime-27.0.0 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs
wasmtime-26.0.0 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs
wasmtime-25.0.2 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs
wasmtime-25.0.1 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs
wasmtime-25.0.0 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs
wasmtime-24.0.0 ./ext/cargo-vendor/ryu-1.0.18/src/pretty/exponent.rs