Skip to content

Commit

Permalink
replace math.MaxInt usage (#1585)
Browse files Browse the repository at this point in the history
This constant is only available in go >= 1.17, so I've inlined its value
so dependents don't have to upgrade their go version.

reference implementation: https://cs.opensource.google/go/go/+/refs/tags/go1.17:src/math/const.go;l=38
  • Loading branch information
David Zukowski authored Sep 12, 2021
1 parent 17e6cb2 commit 40b06d7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package api
import (
"fmt"
"io/ioutil"
"math"
"math/rand"
"os"
"regexp"
Expand Down Expand Up @@ -31,6 +30,11 @@ import (
"github.com/evanw/esbuild/internal/resolver"
)

const (
intSize = 32 << (^uint(0) >> 63)
maxInt = 1<<(intSize-1) - 1
)

func validatePathTemplate(template string) []config.PathTemplate {
if template == "" {
return nil
Expand Down Expand Up @@ -1755,7 +1759,7 @@ func analyzeMetafileImpl(metafile string, opts AnalyzeMetafileOptions) string {
for _, importPath := range importsForPath[top].imports {
imported, ok := graph[importPath]
if !ok {
imported.depth = math.MaxInt
imported.depth = maxInt
}

if imported.depth > childDepth {
Expand Down

0 comments on commit 40b06d7

Please sign in to comment.