Skip to content

Commit

Permalink
chore(stdlib): Leverage Infinity keyword in Regex module (#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake authored Jan 20, 2024
1 parent dd25d02 commit d5e6468
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions stdlib/regex.gr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ include "map"
include "option"
include "result"
include "string"
include "float32"
include "number"
from Number use { min, max }

Expand Down Expand Up @@ -2120,7 +2119,7 @@ let rec validate = (re: ParsedRegularExpression, numGroups) => {
mustSizes = mergeDependsSizes(oldMustSizes, mustSizes)
dependsSizes = mergeDependsSizes(oldDependsSizes, dependsSizes)
let repeatMax = match (repeatMax) {
None => Float32.toNumber(Float32.infinity),
None => Infinity,
Some(n) => n,
}
(min1 * repeatMin, max1 * repeatMax, maxL1)
Expand All @@ -2146,7 +2145,7 @@ let rec validate = (re: ParsedRegularExpression, numGroups) => {
},
RELookbehind(re, _, lbMin, lbMax, _, _) => {
let (min1, max1, maxL1) = loop(re)
if (max1 == Float32.toNumber(Float32.infinity)) {
if (max1 == Infinity) {
thrownError = Some(DoesNotMatchBounded)
(0, 0, 0)
} else {
Expand All @@ -2162,10 +2161,10 @@ let rec validate = (re: ParsedRegularExpression, numGroups) => {
(0, 0, 0)
} else {
match (Map.get(n, groupSizes)) {
Some(minSize) => (minSize, Float32.toNumber(Float32.infinity), 0),
Some(minSize) => (minSize, Infinity, 0),
None => {
Map.set(n - 1, true, dependsSizes)
(1, Float32.toNumber(Float32.infinity), 0)
(1, Infinity, 0)
},
}
}
Expand Down

0 comments on commit d5e6468

Please sign in to comment.