Skip to content

Commit 71a35f0

Browse files
committed
Return early instead of using goto
1 parent 3201a86 commit 71a35f0

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/app/bagrov.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ void Bagrov::nbagro(float *bage, float *y, float *x)
7979
// General helper variable of type float
8080
float h;
8181

82-
y0 = 0.0F;
83-
8482
// Set local bag value to input value bage, but to 20.0 at maximum
8583
// read as: "take the smaller of the two values *bage, 20.0"
8684
bag = MIN(*bage, 20.0);
8785

88-
// If input value x is already below a threshold, return
89-
if (*x < 0.0005F) goto FINISH;
86+
// If input value x is already below a threshold, set y to 0.0 and return
87+
if (*x < 0.0005F) {
88+
*y = 0.0F;
89+
return;
90+
}
9091

9192
// Set input value x to 15.0 at maximum
9293
*x = MIN(*x, 15.0F);
@@ -121,9 +122,10 @@ void Bagrov::nbagro(float *bage, float *y, float *x)
121122
// Limit y0 to its maximum allowed value
122123
y0 = MIN((epa - 1.0F) / (b - c * epa), ALMOST_ONE);
123124

124-
// If bag is between a certain range we have finished
125+
// If bag is between a certain range set y to y0 and return
125126
if (bag >= 0.7F && bag <= 3.8F) {
126-
goto FINISH;
127+
*y = y0;
128+
return;
127129
}
128130

129131
if (bag >= 3.8F) {

0 commit comments

Comments
 (0)