Skip to content

Commit 0ff481e

Browse files
authored
Use json-iterator/go for all JSON operations (#556)
1 parent a396a4e commit 0ff481e

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

SCC-OUTPUT-REPORT.html

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
<tbody><tr>
1414
<th>Go</th>
1515
<th>27</th>
16-
<th>9578</th>
17-
<th>1462</th>
16+
<th>9584</th>
17+
<th>1464</th>
1818
<th>447</th>
19-
<th>7669</th>
19+
<th>7673</th>
2020
<th>1413</th>
21-
<th>255238</th>
22-
<th>4126</th>
21+
<th>255539</th>
22+
<th>4128</th>
2323
</tr><tr>
2424
<td>processor/workers_test.go</td>
2525
<td></td>
@@ -33,13 +33,13 @@
3333
</tr><tr>
3434
<td>processor/formatters.go</td>
3535
<td></td>
36-
<td>1517</td>
36+
<td>1519</td>
3737
<td>208</td>
3838
<td>39</td>
39-
<td>1270</td>
39+
<td>1272</td>
4040
<td>163</td>
41-
<td>44230</td>
42-
<td>784</td>
41+
<td>44361</td>
42+
<td>785</td>
4343
</tr><tr>
4444
<td>processor/formatters_test.go</td>
4545
<td></td>
@@ -93,13 +93,13 @@
9393
</tr><tr>
9494
<td>cmd/badges/main.go</td>
9595
<td></td>
96-
<td>374</td>
96+
<td>375</td>
9797
<td>60</td>
9898
<td>17</td>
99-
<td>297</td>
99+
<td>298</td>
100100
<td>59</td>
101-
<td>9571</td>
102-
<td>239</td>
101+
<td>9660</td>
102+
<td>240</td>
103103
</tr><tr>
104104
<td>processor/workers_tokei_test.go</td>
105105
<td></td>
@@ -213,13 +213,13 @@
213213
</tr><tr>
214214
<td>scripts/include.go</td>
215215
<td></td>
216-
<td>84</td>
217-
<td>16</td>
216+
<td>87</td>
217+
<td>18</td>
218218
<td>9</td>
219-
<td>59</td>
219+
<td>60</td>
220220
<td>19</td>
221-
<td>2207</td>
222-
<td>62</td>
221+
<td>2288</td>
222+
<td>63</td>
223223
</tr><tr>
224224
<td>processor/filereader.go</td>
225225
<td></td>
@@ -294,15 +294,15 @@
294294
<tfoot><tr>
295295
<th>Total</th>
296296
<th>27</th>
297-
<th>9578</th>
298-
<th>1462</th>
297+
<th>9584</th>
298+
<th>1464</th>
299299
<th>447</th>
300-
<th>7669</th>
300+
<th>7673</th>
301301
<th>1413</th>
302-
<th>255238</th>
303-
<th>4126</th>
302+
<th>255539</th>
303+
<th>4128</th>
304304
</tr>
305305
<tr>
306-
<th colspan="9">Estimated Cost to Develop (organic) $229,388<br>Estimated Schedule Effort (organic) 7.86 months<br>Estimated People Required (organic) 2.59<br></th>
306+
<th colspan="9">Estimated Cost to Develop (organic) $229,513<br>Estimated Schedule Effort (organic) 7.86 months<br>Estimated People Required (organic) 2.59<br></th>
307307
</tr></tfoot>
308308
</table></body></html>

cmd/badges/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"encoding/json"
65
"errors"
76
"fmt"
87
"math"
@@ -17,6 +16,7 @@ import (
1716
"time"
1817

1918
"github.com/boyter/scc/v3/processor"
19+
jsoniter "github.com/json-iterator/go"
2020
"github.com/rs/zerolog/log"
2121
)
2222

@@ -25,6 +25,7 @@ var (
2525
cache = NewSimpleCache(1000, 86400)
2626
countingSemaphore = make(chan bool, 1)
2727
tmpDir = os.TempDir()
28+
json = jsoniter.ConfigCompatibleWithStandardLibrary
2829
)
2930

3031
func main() {

processor/formatters.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"bytes"
77
"cmp"
88
"encoding/csv"
9-
"encoding/json"
109
"fmt"
1110
"math"
1211
"os"
@@ -17,6 +16,7 @@ import (
1716
"strings"
1817
"time"
1918

19+
jsoniter "github.com/json-iterator/go"
2020
"github.com/mattn/go-runewidth"
2121

2222
glanguage "golang.org/x/text/language"
@@ -244,6 +244,7 @@ func toJSON(input chan *FileJob) string {
244244
language := aggregateLanguageSummary(input)
245245
language = sortLanguageSummary(language)
246246

247+
json := jsoniter.ConfigCompatibleWithStandardLibrary
247248
jsonString, _ := json.Marshal(language)
248249

249250
if Debug {
@@ -272,6 +273,7 @@ func toJSON2(input chan *FileJob) string {
272273

273274
cost, schedule, people := esstimateCostScheduleMonths(sumCode)
274275

276+
json := jsoniter.ConfigCompatibleWithStandardLibrary
275277
jsonString, _ := json.Marshal(Json2{
276278
LanguageSummary: language,
277279
EstimatedCost: cost,

scripts/include.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ import (
66
"bytes"
77
"compress/gzip"
88
"encoding/base64"
9-
"encoding/json"
109
"fmt"
1110
"io"
1211
"os"
1312
"strings"
13+
14+
jsoniter "github.com/json-iterator/go"
1415
)
1516

1617
const constantsFile = "./processor/constants.go"
1718

19+
var json = jsoniter.ConfigCompatibleWithStandardLibrary
20+
1821
// Reads all .json files in the current folder
1922
// and encodes them as strings literals in constants.go
2023
func generateConstants() error {

0 commit comments

Comments
 (0)