File tree Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -113,19 +113,13 @@ class Hash {
113
113
/// \brief Left-rotate \p x by \p c.
114
114
final
115
115
func rol( _ x: UInt32 , _ c: UInt32 ) -> UInt32 {
116
- // TODO: use the &>> operator.
117
- let a = UInt32 ( truncatingIfNeeded: Int64 ( x) << Int64 ( c) )
118
- let b = UInt32 ( truncatingIfNeeded: Int64 ( x) >> ( 32 - Int64( c) ) )
119
- return a|b
116
+ return x &<< c | x &>> ( 32 &- c)
120
117
}
121
118
122
119
/// \brief Right-rotate \p x by \p c.
123
120
final
124
121
func ror( _ x: UInt32 , _ c: UInt32 ) -> UInt32 {
125
- // TODO: use the &>> operator.
126
- let a = UInt32 ( truncatingIfNeeded: Int64 ( x) >> Int64 ( c) )
127
- let b = UInt32 ( truncatingIfNeeded: Int64 ( x) << ( 32 - Int64( c) ) )
128
- return a|b
122
+ return x &>> c | x &<< ( 32 &- c)
129
123
}
130
124
}
131
125
You can’t perform that action at this time.
0 commit comments