Skip to content

Commit

Permalink
performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
incu6us committed Apr 9, 2020
1 parent 75490d7 commit bef25b8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions reviser/reviser.go
Expand Up @@ -8,7 +8,6 @@ import (
"go/printer"
"go/token"
"io/ioutil"
"log"
"sort"
"strings"

Expand All @@ -23,19 +22,18 @@ func Execute(projectName, filePath string) ([]byte, bool, error) {

fset := token.NewFileSet()

f, err := parser.ParseFile(fset, "", originalContent, parser.ParseComments)
pf, err := parser.ParseFile(fset, "", originalContent, parser.ParseComments)
if err != nil {
log.Println(err)
return nil, false, err
}

imports := combineAllImports(f)
imports := combineAllImports(pf)

stdImports, generalImports, projectImports := groupImports(projectName, imports)

fixImports(f, stdImports, generalImports, projectImports)
fixImports(pf, stdImports, generalImports, projectImports)

fixedImportsContent, err := generateFile(fset, f)
fixedImportsContent, err := generateFile(fset, pf)
if err != nil {
return nil, false, err
}
Expand Down

0 comments on commit bef25b8

Please sign in to comment.