Skip to content

Commit

Permalink
Use exception instead of check
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Haraldsen committed Jan 30, 2024
1 parent 540a45a commit d679e9b
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ private LimitedCharArrayIntegerUtil()
public static int parsePositiveInt(final String strNum, int startInclusive, int endExclusive)
{
int result = 0;
for (int i = startInclusive; i < endExclusive; i++)
try
{
try

for (int i = startInclusive; i < endExclusive; i++)
{
final char c = strNum.charAt(i);
if (c < ZERO || c > DIGIT_9)
Expand All @@ -61,11 +62,12 @@ public static int parsePositiveInt(final String strNum, int startInclusive, int
}
result = result * 10 + (c - ZERO);
}
catch (StringIndexOutOfBoundsException exc)
{
ErrorUtil.raiseUnexpectedEndOfText(strNum, startInclusive);
}
}
catch (StringIndexOutOfBoundsException exc)
{
ErrorUtil.raiseUnexpectedEndOfText(strNum, startInclusive);
}

return result;
}

Expand Down

0 comments on commit d679e9b

Please sign in to comment.