Skip to content

Commit

Permalink
Remove TypeId hacks assuming itoa changes go through
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Saveau committed Nov 20, 2024
1 parent a46a59b commit 2990def
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/path/dec_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,6 @@ impl DecInt {
let mut str_buf = Buffer::new();
let str_buf = str_buf.format(i);
{
let max_buf_size = {
let bits = match TypeId::of::<Int>() {
id if [TypeId::of::<i8>(), TypeId::of::<u8>()].contains(&id) => u8::BITS,
id if [TypeId::of::<i16>(), TypeId::of::<u16>()].contains(&id) => u16::BITS,
id if [TypeId::of::<i32>(), TypeId::of::<u32>()].contains(&id) => u32::BITS,
id if [TypeId::of::<i64>(), TypeId::of::<u64>()].contains(&id) => u64::BITS,
id if [TypeId::of::<i128>(), TypeId::of::<u128>()].contains(&id) => u128::BITS,
id if [TypeId::of::<isize>(), TypeId::of::<usize>()].contains(&id) => {
usize::BITS
}
_ => unreachable!(),
};
match bits {
8 => "-128".len(),
16 => "-32768".len(),
32 => "-2147483648".len(),
64 => "-9223372036854775808".len(),
128 => "-170141183460469231731687303715884105728".len(),
_ => unreachable!(),
}
};
// This optimizes out the assertion and bounds checks.
if str_buf.len() > max_buf_size {
unsafe { core::hint::unreachable_unchecked() }
}
assert!(
str_buf.len() < buf.len(),
"{str_buf}{} unsupported.",
Expand Down

0 comments on commit 2990def

Please sign in to comment.