mirror of
https://github.com/syncthing/syncthing.git
synced 2026-04-05 07:03:48 -04:00
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:
@@ -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()),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user