Merge pull request #2455 from jyk1987/develop

Improve json coding performance
This commit is contained in:
astaxie 2017-02-25 19:01:12 +08:00 committed by GitHub
commit b03b0779dc
1 changed files with 5 additions and 4 deletions

View File

@ -331,16 +331,17 @@ func (output *BeegoOutput) IsServerError() bool {
func stringsToJSON(str string) string {
rs := []rune(str)
jsons := ""
var jsons bytes.Buffer
for _, r := range rs {
rint := int(r)
if rint < 128 {
jsons += string(r)
jsons.WriteRune(r)
} else {
jsons += "\\u" + strconv.FormatInt(int64(rint), 16) // json
jsons.WriteString("\\u")
jsons.WriteString(strconv.FormatInt(int64(rint), 16))
}
}
return jsons
return jsons.String()
}
// Session sets session item value with given key.