Memory usage should be reduced even a bit more, as unused buffer space is now been cut off of decoded static data.

This commit is contained in:
NI
2019-08-14 12:31:01 +08:00
parent 0c12aedbae
commit 1c3527a67a

View File

@@ -161,8 +161,6 @@ import (
"encoding/hex"
)
var raw{{ .GOVariableName }}Data = ` + "`" + `{{ .Data }}` + "`" + `
// {{ .GOVariableName }} returns static file
func {{ .GOVariableName }}() (
int, // FileStart
@@ -181,17 +179,19 @@ func {{ .GOVariableName }}() (
panic(createErr)
}
data, dataErr := hex.DecodeString(raw{{ .GOVariableName }}Data)
raw{{ .GOVariableName }}Data = ""
data, dataErr := hex.DecodeString(` + "`" + `{{ .Data }}` + "`" + `)
if dataErr != nil {
panic(dataErr)
}
shrinkToFit := make([]byte, len(data))
copy(shrinkToFit, data)
return {{ .FileStart }}, {{ .FileEnd }},
{{ .CompressedStart }}, {{ .CompressedEnd }},
"{{ .ContentHash }}", "{{ .CompressedHash }}", created, data
"{{ .ContentHash }}", "{{ .CompressedHash }}", created, shrinkToFit
}
`
)