all: Store assets as strings (#6611)

Storing assets as []byte requires every compiled-in asset to be copied
into writable memory at program startup. That currently takes up 1.6MB
per syncthing process. Strings stay in the RODATA section and should be
shared between processes running the same binary.
This commit is contained in:
greatroar authored and GitHub committed 2020-05-07 11:47:23 +02:00
1 parent 2cdeb1bf70
commit e2febf246e
5 files changed
+21 -25

No files matched your search

+3 -3
View File
@@ -29,8 +29,8 @@ package auto
const Generated int64 = {{.Generated}}
func Assets() map[string][]byte {
var assets = make(map[string][]byte, {{.Assets | len}})
func Assets() map[string]string {
var assets = make(map[string]string, {{.Assets | len}})
{{range $asset := .Assets}}
assets["{{$asset.Name}}"] = {{$asset.Data}}{{end}}
return assets
@@ -72,7 +72,7 @@ func walkerFor(basePath string) filepath.WalkFunc {
name, _ = filepath.Rel(basePath, name)
assets = append(assets, asset{
Name: filepath.ToSlash(name),
Data: fmt.Sprintf("[]byte(%q)", buf.String()),
Data: fmt.Sprintf("%q", buf.String()),
})
}