Skip to content

Commit

Permalink
very slight tweak to performance
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Feb 22, 2021
1 parent 16b42f8 commit 115d78a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 23 deletions.
44 changes: 22 additions & 22 deletions SCC-OUTPUT-REPORT.html
Expand Up @@ -12,12 +12,12 @@
<tbody><tr>
<th>Go</th>
<th>34</th>
<th>8333</th>
<th>1353</th>
<th>362</th>
<th>6618</th>
<th>1367</th>
<th>329715</th>
<th>8378</th>
<th>1357</th>
<th>370</th>
<th>6651</th>
<th>1390</th>
<th>331412</th>
</tr><tr>
<th>Java</th>
<th>24</th>
Expand All @@ -40,11 +40,11 @@
<th>Markdown</th>
<th>11</th>
<th>1228</th>
<th>296</th>
<th>0</th>
<th>932</th>
<th>0</th>
<th>49896</th>
<th>1228</th>
<th>0</th>
<th>49889</th>
</tr><tr>
<th>Python</th>
<th>9</th>
Expand All @@ -67,9 +67,9 @@
<th>License</th>
<th>5</th>
<th>55</th>
<th>12</th>
<th>0</th>
<th>43</th>
<th>0</th>
<th>55</th>
<th>0</th>
<th>3425</th>
</tr><tr>
Expand Down Expand Up @@ -130,9 +130,9 @@
<th>Plain Text</th>
<th>2</th>
<th>31</th>
<th>7</th>
<th>0</th>
<th>24</th>
<th>0</th>
<th>31</th>
<th>0</th>
<th>1474</th>
</tr><tr>
Expand Down Expand Up @@ -363,12 +363,12 @@
</tr><tr>
<th>HTML</th>
<th>1</th>
<th>572</th>
<th>581</th>
<th>0</th>
<th>0</th>
<th>572</th>
<th>581</th>
<th>0</th>
<th>8387</th>
<th>8506</th>
</tr><tr>
<th>JSON</th>
<th>1</th>
Expand Down Expand Up @@ -571,11 +571,11 @@
<tfoot><tr>
<th>Total</th>
<th>168</th>
<th>25426</th>
<th>2892</th>
<th>1682</th>
<th>20852</th>
<th>2310</th>
<th>1768235</th>
<th>25480</th>
<th>2581</th>
<th>1690</th>
<th>21209</th>
<th>2333</th>
<th>1770044</th>
</tr></tfoot>
</table></body></html>
32 changes: 31 additions & 1 deletion processor/workers.go
Expand Up @@ -429,7 +429,37 @@ func CountStats(fileJob *FileJob) {
// if its a simple file then flip into simple check logic
if langFeatures.Simple {
// at this point all we need do is count the newlines
fmt.Println(">>>>SIMPLE", fileJob.Location)
for index := 0; index < int(fileJob.Bytes); index++ {
if isBinary(index, fileJob.Content[index]) {
fileJob.Binary = true
}

// Only check the first 10000 characters for null bytes indicating a binary file
// and if we find it then we return otherwise carry on and ignore binary markers
if index < 10000 && fileJob.Binary {
return
}

if fileJob.Content[index] == '\n' || index >= endPoint {
fileJob.Code++
fileJob.Lines++

if fileJob.Callback != nil {
if !fileJob.Callback.ProcessLine(fileJob, fileJob.Lines, LINE_CODE) {
return
}
}
if Trace {
printTrace(fmt.Sprintf("%s line %d ended with state: %d: counted as code", fileJob.Location, fileJob.Lines, currentState))
}
}
}

if NoLarge && fileJob.Lines >= LargeLineCount {
// Save memory by unsetting the content as we no longer require it
fileJob.Content = nil
return
}
} else {
for index := checkBomSkip(fileJob); index < int(fileJob.Bytes); index++ {
// Based on our current state determine if the state should change by checking
Expand Down

0 comments on commit 115d78a

Please sign in to comment.