Changeset 231347 in webkit for trunk/Source/JavaScriptCore/jit/BinarySwitch.cpp
- Timestamp:
- May 3, 2018, 10:32:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jit/BinarySwitch.cpp
r221954 r231347 138 138 } 139 139 140 class RandomNumberGenerator { 141 public: 142 using result_type = uint32_t; 143 144 RandomNumberGenerator(WeakRandom& weakRandom) 145 : m_weakRandom(weakRandom) 146 { 147 } 148 149 uint32_t operator()() 150 { 151 return m_weakRandom.getUint32(); 152 } 153 154 static constexpr uint32_t min() { return std::numeric_limits<uint32_t>::min(); } 155 static constexpr uint32_t max() { return std::numeric_limits<uint32_t>::max(); } 156 157 private: 158 WeakRandom& m_weakRandom; 159 }; 160 140 161 void BinarySwitch::build(unsigned start, bool hardStart, unsigned end) 141 162 { … … 196 217 localCaseIndices.append(start + i); 197 218 198 std:: random_shuffle(219 std::shuffle( 199 220 localCaseIndices.begin(), localCaseIndices.end(), 200 [this] (unsigned n) { 201 // We use modulo to get a random number in the range we want fully knowing that 202 // this introduces a tiny amount of bias, but we're fine with such tiny bias. 203 return m_weakRandom.getUint32() % n; 204 }); 221 RandomNumberGenerator(m_weakRandom)); 205 222 206 223 for (unsigned i = 0; i < size - 1; ++i) {
Note:
See TracChangeset
for help on using the changeset viewer.