mirror of
https://github.com/uuid-rs/uuid.git
synced 2025-10-02 07:20:40 +00:00
reduce bitshifts in from_u64_pair
This commit is contained in:
parent
4c785e534e
commit
cfc627b2e2
23
benches/new.rs
Normal file
23
benches/new.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#![feature(test)]
|
||||||
|
extern crate test;
|
||||||
|
|
||||||
|
use test::Bencher;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn from_bytes(b: &mut Bencher) {
|
||||||
|
b.iter(|| Uuid::from_bytes([
|
||||||
|
0xF9, 0x16, 0x8C, 0x5E, 0xCE, 0xB2, 0x4F, 0xAA, 0xB6, 0xBF, 0x32, 0x9B, 0xF3, 0x9F,
|
||||||
|
0xA1, 0xE4,
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn from_u128(b: &mut Bencher) {
|
||||||
|
b.iter(|| Uuid::from_u128(0xa1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d8));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn from_u64_pair(b: &mut Bencher) {
|
||||||
|
b.iter(|| Uuid::from_u64_pair(0xa1a2a3a4b1b2c1c2, 0xd1d2d3d4d5d6d7d8));
|
||||||
|
}
|
@ -252,24 +252,7 @@ impl Uuid {
|
|||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub const fn from_u64_pair(high_bits: u64, low_bits: u64) -> Self {
|
pub const fn from_u64_pair(high_bits: u64, low_bits: u64) -> Self {
|
||||||
Uuid::from_bytes([
|
Uuid::from_u128((high_bits as u128 << 64) | low_bits as u128)
|
||||||
(high_bits >> 56) as u8,
|
|
||||||
(high_bits >> 48) as u8,
|
|
||||||
(high_bits >> 40) as u8,
|
|
||||||
(high_bits >> 32) as u8,
|
|
||||||
(high_bits >> 24) as u8,
|
|
||||||
(high_bits >> 16) as u8,
|
|
||||||
(high_bits >> 8) as u8,
|
|
||||||
high_bits as u8,
|
|
||||||
(low_bits >> 56) as u8,
|
|
||||||
(low_bits >> 48) as u8,
|
|
||||||
(low_bits >> 40) as u8,
|
|
||||||
(low_bits >> 32) as u8,
|
|
||||||
(low_bits >> 24) as u8,
|
|
||||||
(low_bits >> 16) as u8,
|
|
||||||
(low_bits >> 8) as u8,
|
|
||||||
low_bits as u8,
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a UUID using the supplied bytes.
|
/// Creates a UUID using the supplied bytes.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user