Skip to content

Commit

Permalink
Migrated JSON library to jsoniter
Browse files Browse the repository at this point in the history
I am speed
  • Loading branch information
TheTipo01 committed Mar 15, 2021
1 parent 3b51c9f commit beed0d4
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 188 deletions.
6 changes: 3 additions & 3 deletions download.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

import (
"encoding/json"
"github.com/bwmarrin/discordgo"
"github.com/bwmarrin/lit"
jsoniter "github.com/json-iterator/go"
"github.com/zmb3/spotify"
"io/ioutil"
"os"
Expand Down Expand Up @@ -59,7 +59,7 @@ func downloadAndPlay(s *discordgo.Session, guildID, channelID, link, user, txtCh

// We parse every track as individual json, because youtube-dl
for _, singleJSON := range splittedOut {
_ = json.Unmarshal([]byte(singleJSON), &ytdl)
_ = jsoniter.ConfigFastest.Unmarshal([]byte(singleJSON), &ytdl)
fileName := ytdl.ID + "-" + ytdl.Extractor

var el Queue
Expand Down Expand Up @@ -177,7 +177,7 @@ func lyrics(song string) []string {
// So we open and unmarshal the json file
file, _ := os.Open(filename)
byteValue, _ := ioutil.ReadAll(file)
_ = json.Unmarshal(byteValue, &lyrics)
_ = jsoniter.ConfigFastest.Unmarshal(byteValue, &lyrics)

// We remove the JSON
_ = file.Close()
Expand Down
18 changes: 11 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/fsnotify/fsnotify v1.4.10-0.20200417215612-7f4cf4dd2b52 // indirect
github.com/go-sql-driver/mysql v1.5.1-0.20201127135436-f6dcc3d870a8
github.com/golang/protobuf v1.4.3 // indirect
github.com/json-iterator/go v1.1.10
github.com/magiconair/properties v1.8.4 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/pelletier/go-toml v1.8.2-0.20201124181426-2e01f733df54 // indirect
Expand All @@ -16,15 +17,18 @@ require (
github.com/spf13/jwalterweatherman v1.1.1-0.20200824194747-ce7498392da6 // indirect
github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c // indirect
github.com/spf13/viper v1.7.2-0.20201203004352-bba82cfc61da
github.com/zmb3/spotify v1.1.0
golang.org/x/crypto v0.0.0-20210218145215-b8e89b74b9df // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b // indirect
github.com/zmb3/spotify v1.1.1
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210315170653-34ac3e1c2000 // indirect
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
modernc.org/libc v1.7.11 // indirect
modernc.org/sqlite v1.8.7
modernc.org/ccgo/v3 v3.9.1 // indirect
modernc.org/sqlite v1.10.0
modernc.org/strutil v1.1.1 // indirect
)
Loading

0 comments on commit beed0d4

Please sign in to comment.