aboutsummaryrefslogtreecommitdiffstats
path: root/util/random/fast.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/random/fast.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/random/fast.cpp')
-rw-r--r--util/random/fast.cpp90
1 files changed, 45 insertions, 45 deletions
diff --git a/util/random/fast.cpp b/util/random/fast.cpp
index 2f98dfc5d3..c4b869318a 100644
--- a/util/random/fast.cpp
+++ b/util/random/fast.cpp
@@ -1,52 +1,52 @@
-#include "fast.h"
-
-#include <util/stream/input.h>
-
+#include "fast.h"
+
+#include <util/stream/input.h>
+
static inline ui32 FixSeq(ui32 seq1, ui32 seq2) noexcept {
- const ui32 mask = (~(ui32)(0)) >> 1;
-
- if ((seq1 & mask) == (seq2 & mask)) {
- return ~seq2;
- }
-
- return seq2;
-}
-
+ const ui32 mask = (~(ui32)(0)) >> 1;
+
+ if ((seq1 & mask) == (seq2 & mask)) {
+ return ~seq2;
+ }
+
+ return seq2;
+}
+
TFastRng64::TFastRng64(ui64 seed1, ui32 seq1, ui64 seed2, ui32 seq2) noexcept
- : R1_(seed1, seq1)
- , R2_(seed2, FixSeq(seq1, seq2))
-{
-}
-
+ : R1_(seed1, seq1)
+ , R2_(seed2, FixSeq(seq1, seq2))
+{
+}
+
TFastRng64::TArgs::TArgs(ui64 seed) noexcept {
- TReallyFastRng32 rng(seed);
-
- Seed1 = rng.GenRand64();
- Seq1 = rng.GenRand();
- Seed2 = rng.GenRand64();
- Seq2 = rng.GenRand();
-}
-
+ TReallyFastRng32 rng(seed);
+
+ Seed1 = rng.GenRand64();
+ Seq1 = rng.GenRand();
+ Seed2 = rng.GenRand64();
+ Seq2 = rng.GenRand();
+}
+
TFastRng64::TArgs::TArgs(IInputStream& entropy) {
- static_assert(sizeof(*this) == 3 * sizeof(ui64), "please, fix me");
- entropy.LoadOrFail(this, sizeof(*this));
-}
-
-template <class T>
+ static_assert(sizeof(*this) == 3 * sizeof(ui64), "please, fix me");
+ entropy.LoadOrFail(this, sizeof(*this));
+}
+
+template <class T>
static inline T Read(IInputStream& in) noexcept {
- T t = T();
-
- in.LoadOrFail(&t, sizeof(t));
-
- return t;
-}
-
+ T t = T();
+
+ in.LoadOrFail(&t, sizeof(t));
+
+ return t;
+}
+
TFastRng32::TFastRng32(IInputStream& entropy)
- : TFastRng32(Read<ui64>(entropy), Read<ui32>(entropy))
-{
-}
-
+ : TFastRng32(Read<ui64>(entropy), Read<ui32>(entropy))
+{
+}
+
TReallyFastRng32::TReallyFastRng32(IInputStream& entropy)
- : TReallyFastRng32(Read<ui64>(entropy))
-{
-}
+ : TReallyFastRng32(Read<ui64>(entropy))
+{
+}