Skip to content

Commit

Permalink
Some small optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
andeya committed May 16, 2016
1 parent b0b0a7d commit 2b6710a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,16 +515,14 @@ func (c *context) JSON(code int, i interface{}) (err error) {

func (c *context) JSONMsg(code int, msgcode int, info interface{}) (err error) {
var b []byte
i := CommMsg{
Code: msgcode,
Info: info,
}
if c.echo.Debug() {
b, err = json.MarshalIndent(CommMsg{
Code: msgcode,
Info: info,
}, "", " ")
b, err = json.MarshalIndent(i, "", " ")
} else {
b, err = json.Marshal(CommMsg{
Code: msgcode,
Info: info,
})
b, err = json.Marshal(i)
}
if err != nil {
return err
Expand Down Expand Up @@ -566,16 +564,14 @@ func (c *context) JSONP(code int, callback string, i interface{}) (err error) {

func (c *context) JSONPMsg(code int, callback string, msgcode int, info interface{}) (err error) {
var b []byte
i := CommMsg{
Code: msgcode,
Info: info,
}
if c.echo.Debug() {
b, err = json.MarshalIndent(CommMsg{
Code: msgcode,
Info: info,
}, "", " ")
b, err = json.MarshalIndent(i, "", " ")
} else {
b, err = json.Marshal(CommMsg{
Code: msgcode,
Info: info,
})
b, err = json.Marshal(i)
}
if err != nil {
return err
Expand Down

0 comments on commit 2b6710a

Please sign in to comment.