We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0791603 commit 4c28f1bCopy full SHA for 4c28f1b
src/runtime/algorithm.go
@@ -0,0 +1,22 @@
1
+package runtime
2
+
3
+// This file implements various core algorithms used in the runtime package and
4
+// standard library.
5
6
+// This function is used by hash/maphash.
7
+func fastrand() uint32 {
8
+ xorshift32State = xorshift32(xorshift32State)
9
+ return xorshift32State
10
+}
11
12
+var xorshift32State uint32 = 1
13
14
+func xorshift32(x uint32) uint32 {
15
+ // Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs".
16
+ // Improved sequence based on
17
+ // http://www.iro.umontreal.ca/~lecuyer/myftp/papers/xorshift.pdf
18
+ x ^= x << 7
19
+ x ^= x >> 1
20
+ x ^= x << 9
21
+ return x
22
0 commit comments