diff options
author | Jakob Borg <jakob@kastelo.net> | 2018-04-11 23:02:14 +0200 |
---|---|---|
committer | Audrius Butkevicius <audrius.butkevicius@gmail.com> | 2018-04-11 22:02:14 +0100 |
commit | 5fa9237a62be37eaefa5f35b3a1ef61d4a845e5f (patch) | |
tree | 6009522d3d63d41d4cd6f66c4a3420d696de44d0 /script | |
parent | fa367e92b069f3e3fdb3a607001b0aa97376680e (diff) | |
download | syncthing-5fa9237a62be37eaefa5f35b3a1ef61d4a845e5f.tar.gz syncthing-5fa9237a62be37eaefa5f35b3a1ef61d4a845e5f.zip |
script: Don't base64 encode the assets (#4874)
We did this to minimize source size and make it compile faster. Nowadays
byte slice literals compile as fast as anything, and the source isn't
checked in so it doesn't matter how big it is.
Not using base64 avoids a decode step at startup and makes the binary
about 400k smaller.
Diffstat (limited to 'script')
-rw-r--r-- | script/genassets.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/script/genassets.go b/script/genassets.go index d5fd398c8..dcda34e8d 100644 --- a/script/genassets.go +++ b/script/genassets.go @@ -11,8 +11,8 @@ package main import ( "bytes" "compress/gzip" - "encoding/base64" "flag" + "fmt" "go/format" "io" "os" @@ -23,14 +23,10 @@ import ( var tpl = template.Must(template.New("assets").Parse(`package auto -import ( - "encoding/base64" -) - func Assets() map[string][]byte { var assets = make(map[string][]byte, {{.Assets | len}}) {{range $asset := .Assets}} - assets["{{$asset.Name}}"], _ = base64.StdEncoding.DecodeString("{{$asset.Data}}"){{end}} + assets["{{$asset.Name}}"] = {{$asset.Data}}{{end}} return assets } @@ -70,7 +66,7 @@ func walkerFor(basePath string) filepath.WalkFunc { name, _ = filepath.Rel(basePath, name) assets = append(assets, asset{ Name: filepath.ToSlash(name), - Data: base64.StdEncoding.EncodeToString(buf.Bytes()), + Data: fmt.Sprintf("%#v", buf.Bytes()), // "[]byte{0x00, 0x01, ...}" }) } |