fn breakPatterns(a: usize, b: usize, context: anytype) void a: usizeb: usizecontext326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346fn breakPatterns(a: usize, b: usize, context: anytype) void {
@branchHint(.cold);
const len = b - a;
if (len < 8) return;
var rand = @as(u64, @intCast(len));
const modulus = math.ceilPowerOfTwoAssert(u64, len);
var i = a + (len / 4) * 2 - 1;
while (i <= a + (len / 4) * 2 + 1) : (i += 1) {
// xorshift64
rand ^= rand << 13;
rand ^= rand >> 7;
rand ^= rand << 17;
var other = @as(usize, @intCast(rand & (modulus - 1)));
if (other >= len) other -= len;
context.swap(i, a + other);
}
}