diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2025-01-17 10:28:16 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2025-01-17 10:02:07 +0000 |
| commit | 5d04aae8969f6c72318ce0a4cde4f027766b1a55 (patch) | |
| tree | 8f1b632847c431407090f0fe1335522ff2195a37 /prog/collide.go | |
| parent | f9e07a6e597b68d3397864e6ee4550f9065c3518 (diff) | |
all: use min/max functions
They are shorter, more readable, and don't require temp vars.
Diffstat (limited to 'prog/collide.go')
| -rw-r--r-- | prog/collide.go | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/prog/collide.go b/prog/collide.go index 67cca6ecb..3c8a076a1 100644 --- a/prog/collide.go +++ b/prog/collide.go @@ -105,18 +105,10 @@ func DupCallCollide(origProg *Prog, rand *rand.Rand) (*Prog, error) { // For 1-call programs the behavior is similar to DoubleExecCollide. return nil, fmt.Errorf("the prog is too small for the transformation") } - // By default let's duplicate 1/3 calls in the original program. - insert := len(origProg.Calls) / 3 - if insert == 0 { - // .. but always at least one. - insert = 1 - } - if insert > maxAsyncPerProg { - insert = maxAsyncPerProg - } - if insert+len(origProg.Calls) > MaxCalls { - insert = MaxCalls - len(origProg.Calls) - } + // By default let's duplicate 1/3 calls in the original program (but at least one). + insert := max(len(origProg.Calls)/3, 1) + insert = min(insert, maxAsyncPerProg) + insert = min(insert, MaxCalls-len(origProg.Calls)) if insert == 0 { return nil, fmt.Errorf("no calls could be duplicated") } |
