Skip to content

Commit

Permalink
Use built-in less than operator instead of strings.Compare
Browse files Browse the repository at this point in the history
  • Loading branch information
edsrzf committed Sep 2, 2018
1 parent b48c6b9 commit c770b4e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion codegen/enum_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (cfg *Config) buildEnums(types NamedTypes) []Enum {
}

sort.Slice(enums, func(i, j int) bool {
return strings.Compare(enums[i].GQLType, enums[j].GQLType) == -1
return enums[i].GQLType < enums[j].GQLType
})

return enums
Expand Down
3 changes: 1 addition & 2 deletions codegen/input_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package codegen
import (
"go/types"
"sort"
"strings"

"github.com/pkg/errors"
"github.com/vektah/gqlparser/ast"
Expand Down Expand Up @@ -38,7 +37,7 @@ func (cfg *Config) buildInputs(namedTypes NamedTypes, prog *loader.Program, impo
}

sort.Slice(inputs, func(i, j int) bool {
return strings.Compare(inputs[i].GQLType, inputs[j].GQLType) == -1
return inputs[i].GQLType < inputs[j].GQLType
})

return inputs, nil
Expand Down
3 changes: 1 addition & 2 deletions codegen/interface_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"go/types"
"os"
"sort"
"strings"

"github.com/vektah/gqlparser/ast"
"golang.org/x/tools/go/loader"
Expand All @@ -20,7 +19,7 @@ func (cfg *Config) buildInterfaces(types NamedTypes, prog *loader.Program) []*In
}

sort.Slice(interfaces, func(i, j int) bool {
return strings.Compare(interfaces[i].GQLType, interfaces[j].GQLType) == -1
return interfaces[i].GQLType < interfaces[j].GQLType
})

return interfaces
Expand Down
3 changes: 1 addition & 2 deletions codegen/models_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package codegen

import (
"sort"
"strings"

"github.com/vektah/gqlparser/ast"
"golang.org/x/tools/go/loader"
Expand Down Expand Up @@ -47,7 +46,7 @@ func (cfg *Config) buildModels(types NamedTypes, prog *loader.Program, imports *
}

sort.Slice(models, func(i, j int) bool {
return strings.Compare(models[i].GQLType, models[j].GQLType) == -1
return models[i].GQLType < models[j].GQLType
})

return models, nil
Expand Down
3 changes: 1 addition & 2 deletions codegen/object_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package codegen
import (
"log"
"sort"
"strings"

"github.com/pkg/errors"
"github.com/vektah/gqlparser/ast"
Expand Down Expand Up @@ -38,7 +37,7 @@ func (cfg *Config) buildObjects(types NamedTypes, prog *loader.Program, imports
}

sort.Slice(objects, func(i, j int) bool {
return strings.Compare(objects[i].GQLType, objects[j].GQLType) == -1
return objects[i].GQLType < objects[j].GQLType
})

return objects, nil
Expand Down

0 comments on commit c770b4e

Please sign in to comment.