Skip to content

Commit 19d7487

Browse files
committed
Add benchmarks for decode::into_vec_unsafe
1 parent c8b5a90 commit 19d7487

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

benches/decode.rs

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ macro_rules! group_decode {
2424
let mut output = [0; $decoded_length];
2525
b.iter(|| bs58::decode($encoded).into(&mut output).unwrap());
2626
});
27+
group.bench_function("decode_bs58_unsafe", |b| {
28+
b.iter(|| bs58::decode($encoded).into_vec_unsafe().unwrap())
29+
});
2730
group.finish();
2831
}};
2932
}
@@ -44,6 +47,9 @@ macro_rules! group_decode_long {
4447
let mut output = [0; $decoded_length];
4548
b.iter(|| bs58::decode($encoded).into(&mut output[..]).unwrap());
4649
});
50+
group.bench_function("decode_bs58_unsafe", |b| {
51+
b.iter(|| bs58::decode($encoded).into_vec_unsafe().unwrap())
52+
});
4753
// bs58_noalloc_array is not possible because of limited array lengths in trait impls
4854
group.finish();
4955
}};

tests/decode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use assert_matches::assert_matches;
77
fn test_decode() {
88
for &(val, s) in cases::TEST_CASES.iter() {
99
assert_eq!(val.to_vec(), bs58::decode(s).into_vec().unwrap());
10-
assert_eq!(val.to_vec(), bs58::decode::DecodeBuilder::new(s, bs58::Alphabet::DEFAULT).into_vec_unsafe().unwrap());
10+
assert_eq!(val.to_vec(), bs58::decode(s).into_vec_unsafe().unwrap());
1111
}
1212
}
1313

0 commit comments

Comments
 (0)