Skip to content

Commit

Permalink
Switch some asserts to debug asserts, since they can't occur in pract…
Browse files Browse the repository at this point in the history
…ice.
  • Loading branch information
sciguyryan committed Jan 20, 2025
1 parent eb26c9b commit bfe2a19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions psistega3-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ enum ActionType {
fn main() {
SimpleLogger::new().init().unwrap();

use std::time::Instant;
let now = Instant::now();

{
for _ in 0..50 {
let mut s = StegaV1::new("aaaa");
let _ = s.encode(
"D:\\Pictures\\Jeff's Wallpapers\\RJ 1.png",
"aaaaaa".to_string(),
"aaaaaaaaaa",
"D:\\Temp\\output.png",
);
}
}

let elapsed = now.elapsed();
println!("Elapsed: {:.2?}", elapsed / 50);
return;

let mut args: Vec<String> = env::args().collect();
if args.len() == 1 {
show_help();
Expand Down
6 changes: 3 additions & 3 deletions psistega3-core/src/codecs/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ impl DataDecoder {
/// Pop a XOR-decoded byte from the front of the byte list.
///
pub fn pop_u8(&mut self) -> u8 {
assert!(!self.bytes.is_empty(), "insufficient values available");
debug_assert!(!self.bytes.is_empty(), "insufficient values available");

// We do not need to worry about decoding these values from little
// Endian because that will have been done when loading the values.
Expand All @@ -965,7 +965,7 @@ impl DataDecoder {
/// `Note:` this method will automatically convert the returned value from little Endian to the correct bit-format.
///
pub fn pop_u32(&mut self) -> u32 {
assert!(self.bytes.len() >= 4, "insufficient values available");
debug_assert!(self.bytes.len() >= 4, "insufficient values available");

let mut bytes = [0u8; 4];
bytes.iter_mut().for_each(|i| {
Expand All @@ -980,7 +980,7 @@ impl DataDecoder {
/// `Note:` This method will pop `2` bytes from the internal vector for each byte returned.
///
pub fn pop_vec(&mut self, count: usize) -> Vec<u8> {
assert!(self.bytes.len() >= count, "insufficient values available");
debug_assert!(self.bytes.len() >= count, "insufficient values available");

let mut bytes = Vec::with_capacity(count);
for _ in 0..count {
Expand Down

0 comments on commit bfe2a19

Please sign in to comment.