Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
debug assert
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jun 10, 2022
1 parent 0506acf commit 8b84f3d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/util/lexical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ pub fn lexical_to_bytes_mut<N: lexical_core::ToLexical>(n: N, buf: &mut Vec<u8>)

// Safety:
// Omits an unneeded bound check as we just ensured that we reserved `N::FORMATTED_SIZE_DECIMAL`
let len = lexical_core::write_unchecked(n, slice).len();
buf.set_len(len);
#[cfg(debug_assertions)]
{
let len = lexical_core::write(n, slice).len();
buf.set_len(len);
}
#[cfg(not(debug_assertions))]
{
let len = lexical_core::write_unchecked(n, slice).len();
buf.set_len(len);
}
}
}

Expand Down

0 comments on commit 8b84f3d

Please sign in to comment.