Debian Codegraph @

src/murmur3.rs

raw symbols SCIP
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#;
3
4 use byteorderrust-analyzer cargo byteorder 1.4.3 crate/::{ByteOrderrust-analyzer cargo byteorder 1.4.3 ByteOrder#, LErust-analyzer cargo byteorder 1.4.3 LE#};
5
6 use craterust-analyzer cargo hash32 0.3.1 crate/::Hasherrust-analyzer cargo hash32 0.3.1 Hasher# as _;
7
8 /// 32-bit MurmurHash3 hasher
9 pub struct Hasherrust-analyzer cargo hash32 0.3.1 murmur3/Hasher# {
10 bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf.: Bufferrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#,
11 indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index.: Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#,
12 processedrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#processed.: u32,
13 staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state.: Staterust-analyzer cargo hash32 0.3.1 murmur3/State#,
14 }
15
16 struct Staterust-analyzer cargo hash32 0.3.1 murmur3/State#(u32);
17
18 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)]
19 #[repr(align(4))]
20 struct Bufferrust-analyzer cargo hash32 0.3.1 murmur3/Buffer# {
21 bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes.: MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#<[u8; 4]>,
22 }
23
24 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
25 enum Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index# {
26 _0rust-analyzer cargo hash32 0.3.1 murmur3/Index#_0#,
27 _1rust-analyzer cargo hash32 0.3.1 murmur3/Index#_1#,
28 _2rust-analyzer cargo hash32 0.3.1 murmur3/Index#_2#,
29 _3rust-analyzer cargo hash32 0.3.1 murmur3/Index#_3#,
30 }
31
32 impl Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index# {
33 fn usizerust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index]usize().(&self) -> usize {
34 match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self {
35 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_0rust-analyzer cargo hash32 0.3.1 murmur3/Index#_0# => 0,
36 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_1rust-analyzer cargo hash32 0.3.1 murmur3/Index#_1# => 1,
37 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_2rust-analyzer cargo hash32 0.3.1 murmur3/Index#_2# => 2,
38 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_3rust-analyzer cargo hash32 0.3.1 murmur3/Index#_3# => 3,
39 }
40 }
41 }
42
43 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<usize> for Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index# {
44 fn fromrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index][`From<usize>`]from().(x: usize) -> Selfrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index][`From<usize>`] {
45 match x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().4 {
46 0 => Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_0rust-analyzer cargo hash32 0.3.1 murmur3/Index#_0#,
47 1 => Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_1rust-analyzer cargo hash32 0.3.1 murmur3/Index#_1#,
48 2 => Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_2rust-analyzer cargo hash32 0.3.1 murmur3/Index#_2#,
49 3 => Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_3rust-analyzer cargo hash32 0.3.1 murmur3/Index#_3#,
50 _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(),
51 }
52 }
53 }
54
55 impl Hasherrust-analyzer cargo hash32 0.3.1 murmur3/Hasher# {
56 fn pushrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher]push().(&mut self, buf: &[u8]) {
57 let start = self.indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index..usizerust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index]usize().();
58 let len = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
59 // NOTE(unsafe) avoid calling `memcpy` on a 0-3 byte copy
60 // self.buf.bytes[start..start+len].copy_from(buf);
61 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#len {
62 unsafe {
63 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_mut().().get_unchecked_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked_mut().(start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().i) = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().buf.get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(i);
64 }
65 }
66 self.indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index. = Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::fromrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index][`From<usize>`]from().(start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().len);
67 }
68 }
69
70 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Hasherrust-analyzer cargo hash32 0.3.1 murmur3/Hasher# {
71 #[allow(deprecated)]
72 fn defaultrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher][Default]default().() -> Selfrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher][Default] {
73 Hasherrust-analyzer cargo hash32 0.3.1 murmur3/Hasher# {
74 bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf.: Bufferrust-analyzer cargo hash32 0.3.1 murmur3/Buffer# { bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes.: MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::uninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]uninit().() },
75 indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index.: Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_0rust-analyzer cargo hash32 0.3.1 murmur3/Index#_0#,
76 processedrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#processed.: 0,
77 staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state.: Staterust-analyzer cargo hash32 0.3.1 murmur3/State#(0),
78 }
79 }
80 }
81
82 impl craterust-analyzer cargo hash32 0.3.1 crate/::Hasherrust-analyzer cargo hash32 0.3.1 Hasher# for Hasherrust-analyzer cargo hash32 0.3.1 murmur3/Hasher# {
83 fn finish32rust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher][Hasher]finish32().(&self) -> u32 {
84 // tail
85 let mut state = match self.indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index. {
86 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_3rust-analyzer cargo hash32 0.3.1 murmur3/Index#_3# => {
87 let mut block = 0;
88 unsafe {
89 block rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u8>`]from().(self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_ref().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().16;
90 block rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u8>`]from().(self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_ref().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().8;
91 block rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u8>`]from().(self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_ref().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
92 }
93 self.staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state..0rust-analyzer cargo hash32 0.3.1 murmur3/State#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().pre_mixrust-analyzer cargo hash32 0.3.1 murmur3/pre_mix().(block)
94 }
95 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_2rust-analyzer cargo hash32 0.3.1 murmur3/Index#_2# => {
96 let mut block = 0;
97 unsafe {
98 block rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u8>`]from().(self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_ref().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().8;
99 block rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u8>`]from().(self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_ref().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
100 }
101 self.staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state..0rust-analyzer cargo hash32 0.3.1 murmur3/State#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().pre_mixrust-analyzer cargo hash32 0.3.1 murmur3/pre_mix().(block)
102 }
103 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_1rust-analyzer cargo hash32 0.3.1 murmur3/Index#_1# => {
104 let mut block = 0;
105 unsafe {
106 block rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u8>`]from().(self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_ref().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
107 }
108 self.staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state..0rust-analyzer cargo hash32 0.3.1 murmur3/State#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().pre_mixrust-analyzer cargo hash32 0.3.1 murmur3/pre_mix().(block)
109 }
110 Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_0rust-analyzer cargo hash32 0.3.1 murmur3/Index#_0# => self.staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state..0rust-analyzer cargo hash32 0.3.1 murmur3/State#0.,
111 };
112
113 // finalization mix
114 state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().self.processedrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#processed.;
115 state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().16;
116 state = state.wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_mul().(0x85ebca6b);
117 state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().13;
118 state = state.wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_mul().(0xc2b2ae35);
119 state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().state rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().16;
120
121 state
122 }
123 }
124
125 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher# for Hasherrust-analyzer cargo hash32 0.3.1 murmur3/Hasher# {
126 #[inline]
127 fn writerust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher][Hasher]write().(&mut self, bytes: &[u8]) {
128 let len = bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
129 self.processedrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#processed. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().len as u32;
130
131 let body = if self.indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index. rust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index][`PartialEq<Self>`]eq().==rust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index][`PartialEq<Self>`]eq(). rust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index][`PartialEq<Self>`]eq().Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_0rust-analyzer cargo hash32 0.3.1 murmur3/Index#_0# {
132 bytes
133 } else {
134 let index = self.indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index..usizerust-analyzer cargo hash32 0.3.1 murmur3/impl#[Index]usize().();
135 if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().4 {
136 // we can complete a block using the data left in the buffer
137 // NOTE(unsafe) avoid panicking branch (`slice_index_len_fail`)
138 // let (head, body) = bytes.split_at(4 - index);
139 let mid = 4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().index;
140 let head = unsafe { slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::from_raw_partsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_raw_parts().(bytes.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(), mid) };
141 let body = unsafe {
142 slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::from_raw_partsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_raw_parts().(bytes.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().().offsetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]offset().(mid as isize), len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().mid)
143 };
144
145 // NOTE(unsafe) avoid calling `memcpy` on a 0-3 byte copy
146 // self.buf.bytes[index..].copy_from_slice(head);
147 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().index {
148 unsafe {
149 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes..assume_init_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_mut().().get_unchecked_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked_mut().(index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().i) = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().head.get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(i);
150 }
151 }
152
153 self.indexrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#index. = Indexrust-analyzer cargo hash32 0.3.1 murmur3/Index#::_0rust-analyzer cargo hash32 0.3.1 murmur3/Index#_0#;
154
155 self.staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state..process_blockrust-analyzer cargo hash32 0.3.1 murmur3/impl#[State]process_block().(&self.bufrust-analyzer cargo hash32 0.3.1 murmur3/Hasher#buf..bytesrust-analyzer cargo hash32 0.3.1 murmur3/Buffer#bytes.);
156
157 body
158 } else {
159 bytes
160 }
161 };
162
163 for block in body.chunksrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks().(4) {
164 if block.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().4 {
165 self.staterust-analyzer cargo hash32 0.3.1 murmur3/Hasher#state.
166 .process_blockrust-analyzer cargo hash32 0.3.1 murmur3/impl#[State]process_block().(unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(block.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as *const _) });
167 } else {
168 self.pushrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher]push().(block);
169 }
170 }
171
172 // XXX is this faster?
173 // for block in body.exact_chunks(4) {
174 // self.state
175 // .process_block(unsafe { &*(block.as_ptr() as *const _) });
176 // }
177
178 // let tail = body.split_at(body.len() / 4 * 4).1;
179
180 // self.push(tail);
181 }
182
183 #[inline]
184 fn finishrust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher][Hasher]finish().(&self) -> u64 {
185 self.finish32rust-analyzer cargo hash32 0.3.1 murmur3/impl#[Hasher][Hasher]finish32().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
186 }
187 }
188
189 const C1rust-analyzer cargo hash32 0.3.1 murmur3/C1.: u32 = 0xcc9e2d51;
190 const C2rust-analyzer cargo hash32 0.3.1 murmur3/C2.: u32 = 0x1b873593;
191 const R1rust-analyzer cargo hash32 0.3.1 murmur3/R1.: u32 = 15;
192
193 impl Staterust-analyzer cargo hash32 0.3.1 murmur3/State# {
194 fn process_blockrust-analyzer cargo hash32 0.3.1 murmur3/impl#[State]process_block().(&mut self, block: &MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#<[u8; 4]>) {
195 self.0rust-analyzer cargo hash32 0.3.1 murmur3/State#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().^=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXorAssign<Self>`]bitxor_assign().pre_mixrust-analyzer cargo hash32 0.3.1 murmur3/pre_mix().(LErust-analyzer cargo byteorder 1.4.3 LE#::read_u32rust-analyzer cargo byteorder 1.4.3 impl#[LittleEndian][ByteOrder]read_u32().(unsafe { block.assume_init_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init_ref().() }));
196 self.0rust-analyzer cargo hash32 0.3.1 murmur3/State#0. = self.0rust-analyzer cargo hash32 0.3.1 murmur3/State#0..rotate_leftrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]rotate_left().(13);
197 self.0rust-analyzer cargo hash32 0.3.1 murmur3/State#0. = 5u32.wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_mul().(self.0rust-analyzer cargo hash32 0.3.1 murmur3/State#0.).wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(0xe6546b64);
198 }
199 }
200
201 fn pre_mixrust-analyzer cargo hash32 0.3.1 murmur3/pre_mix().(mut block: u32) -> u32 {
202 block = block.wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_mul().(C1rust-analyzer cargo hash32 0.3.1 murmur3/C1.);
203 block = block.rotate_leftrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]rotate_left().(R1rust-analyzer cargo hash32 0.3.1 murmur3/R1.);
204 block = block.wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_mul().(C2rust-analyzer cargo hash32 0.3.1 murmur3/C2.);
205 block
206 }