Replace as_ptr().offset(...) with get_unchecked(...)

This commit is contained in:
David Tolnay
2018-07-28 22:06:00 -07:00
parent 9e3ae8a896
commit bd3fad5507
2 changed files with 9 additions and 9 deletions
+5 -5
View File
@@ -305,12 +305,12 @@ pub unsafe fn d2s_buffered_n(f: f64, result: *mut u8) -> usize {
let c0 = (c % 100) << 1;
let c1 = (c / 100) << 1;
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset(c0 as isize),
DIGIT_TABLE.get_unchecked(c0 as usize),
result.offset(index + olength as isize - i - 1),
2,
);
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset(c1 as isize),
DIGIT_TABLE.get_unchecked(c1 as usize),
result.offset(index + olength as isize - i - 3),
2,
);
@@ -320,7 +320,7 @@ pub unsafe fn d2s_buffered_n(f: f64, result: *mut u8) -> usize {
let c = ((output2 % 100) << 1) as u32;
output2 /= 100;
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset(c as isize),
DIGIT_TABLE.get_unchecked(c as usize),
result.offset(index + olength as isize - i - 1),
2,
);
@@ -355,7 +355,7 @@ pub unsafe fn d2s_buffered_n(f: f64, result: *mut u8) -> usize {
if exp >= 100 {
let c = exp % 10;
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset((2 * (exp / 10)) as isize),
DIGIT_TABLE.get_unchecked((2 * (exp / 10)) as usize),
result.offset(index),
2,
);
@@ -363,7 +363,7 @@ pub unsafe fn d2s_buffered_n(f: f64, result: *mut u8) -> usize {
index += 3;
} else if exp >= 10 {
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset((2 * exp) as isize),
DIGIT_TABLE.get_unchecked((2 * exp) as usize),
result.offset(index),
2,
);
+4 -4
View File
@@ -344,12 +344,12 @@ pub unsafe fn f2s_buffered_n(f: f32, result: *mut u8) -> usize {
let c0 = (c % 100) << 1;
let c1 = (c / 100) << 1;
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset(c0 as isize),
DIGIT_TABLE.get_unchecked(c0 as usize),
result.offset(index + olength as isize - i - 1),
2,
);
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset(c1 as isize),
DIGIT_TABLE.get_unchecked(c1 as usize),
result.offset(index + olength as isize - i - 3),
2,
);
@@ -359,7 +359,7 @@ pub unsafe fn f2s_buffered_n(f: f32, result: *mut u8) -> usize {
let c = (output % 100) << 1;
output /= 100;
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset(c as isize),
DIGIT_TABLE.get_unchecked(c as usize),
result.offset(index + olength as isize - i - 1),
2,
);
@@ -393,7 +393,7 @@ pub unsafe fn f2s_buffered_n(f: f32, result: *mut u8) -> usize {
if exp >= 10 {
ptr::copy_nonoverlapping(
DIGIT_TABLE.as_ptr().offset((2 * exp) as isize),
DIGIT_TABLE.get_unchecked((2 * exp) as usize),
result.offset(index),
2,
);