Skip to content

Commit

Permalink
Prepare for release 1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Sep 3, 2018
1 parent e7069d6 commit 3268bee
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 39 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

//go:generate go run scripts/include.go
func main() {
// f, _ := os.Create("scc.pprof")
// pprof.StartCPUProfile(f)
// defer pprof.StopCPUProfile()
//f, _ := os.Create("scc.pprof")
//pprof.StartCPUProfile(f)
//defer pprof.StopCPUProfile()
// defer profile.Start(profile.CPUProfile).Stop()
// defer profile.Start(profile.MemProfile).Stop()

Expand Down
70 changes: 34 additions & 36 deletions processor/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ func CountStats(fileJob *FileJob) {

// Check if this file is binary by checking for nul byte and if so bail out
// this is how GNU Grep, git and ripgrep check for binary files
// TODO limit this to the first 10000 chars
if isBinary(fileJob.Content[index]) {
if index < 10000 && isBinary(fileJob.Content[index]) {
fileJob.Binary = true
return
}
Expand All @@ -248,41 +247,7 @@ func CountStats(fileJob *FileJob) {
if !isWhitespace(fileJob.Content[index]) {
state:
switch {
case currentState == S_BLANK || currentState == S_MULTICOMMENT_BLANK:
// From blank we can move into comment, move into a multiline comment
// or move into code but we can only do one.
if checkForMatch(fileJob.Content[index], index, endPoint, singleLineCommentChecks, fileJob) {
currentState = S_COMMENT
break state
}

if nested || len(endComments) == 0 {
offsetJump, endString = checkForMatchMultiOpen(fileJob.Content[index], index, endPoint, multiLineCommentChecks, fileJob)
if offsetJump != 0 {
endComments = append(endComments, endString)
currentState = S_MULTICOMMENT
index += offsetJump - 1
break state
}
}

// TODO test if moving this line up above comment checks improves performance
offsetJump, endString = checkForMatchMultiOpen(fileJob.Content[index], index, endPoint, stringChecks, fileJob)
if offsetJump != 0 {
currentState = S_STRING
break state
}


currentState = S_CODE
if !Complexity {
offsetJump = checkComplexity(fileJob.Content[index], index, endPoint, complexityChecks, complexityBytes, fileJob)
if offsetJump != 0 {
fileJob.Complexity++
}
}
case currentState == S_CODE:
// From code we can move into a multiline comment or string
if nested || len(endComments) == 0 {
offsetJump, endString = checkForMatchMultiOpen(fileJob.Content[index], index, endPoint, multiLineCommentChecks, fileJob)
if offsetJump != 0 {
Expand Down Expand Up @@ -348,6 +313,39 @@ func CountStats(fileJob *FileJob) {

index += offsetJump - 1
}
case currentState == S_BLANK || currentState == S_MULTICOMMENT_BLANK:
// From blank we can move into comment, move into a multiline comment
// or move into code but we can only do one.
if checkForMatch(fileJob.Content[index], index, endPoint, singleLineCommentChecks, fileJob) {
currentState = S_COMMENT
break state
}

if nested || len(endComments) == 0 {
offsetJump, endString = checkForMatchMultiOpen(fileJob.Content[index], index, endPoint, multiLineCommentChecks, fileJob)
if offsetJump != 0 {
endComments = append(endComments, endString)
currentState = S_MULTICOMMENT
index += offsetJump - 1
break state
}
}

// TODO test if moving this line up above comment checks improves performance
offsetJump, endString = checkForMatchMultiOpen(fileJob.Content[index], index, endPoint, stringChecks, fileJob)
if offsetJump != 0 {
currentState = S_STRING
break state
}


currentState = S_CODE
if !Complexity {
offsetJump = checkComplexity(fileJob.Content[index], index, endPoint, complexityChecks, complexityBytes, fileJob)
if offsetJump != 0 {
fileJob.Complexity++
}
}
}
}

Expand Down

0 comments on commit 3268bee

Please sign in to comment.