pub fn eosWeightedWithHash(s: *Smith, weights: []const Weight, hash: u32) bool 528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551pub fn eosWeightedWithHash(s: *Smith, weights: []const Weight, hash: u32) bool {
@disableInstrumentation();
checkWeights(weights, 1);
for (weights) |w| (if (w.max == 1) break) else unreachable; // `true` must have non-zero weight
if (s.in) |*in| {
if (in.len == 0) {
@branchHint(.unlikely);
return true;
}
const eos_val = in.*[0] != 0;
in.* = in.*[1..];
return eos_val or b: {
var only_true: bool = true;
for (weights) |w| {
only_true &= @as(u1, @intCast(w.min)) == 1;
}
break :b only_true;
};
} else if (builtin.fuzz) {
@branchHint(.likely);
return fuzz_abi.fuzzer_eos(intUid(hash), .fromSlice(weights));
} else unreachable;
}
This is similar to
value(bool)however it is gauraunteed to eventually returntrueand provides the fuzzer with an extra hint about the data.It is asserted that the weight of
trueis non-zero.