1
0
Fork 0
forked from forgejo/forgejo

Refactor struct's time to remove unnecessary memory usage (#3142)

* refactor struct's time to remove unnecessary memory usage

* use AsTimePtr simple code

* fix tests

* fix time compare

* fix template on gpg

* use AddDuration instead of Add
This commit is contained in:
Lunny Xiao 2017-12-11 12:37:04 +08:00 committed by Lauris BH
parent c082c3bce3
commit f2e20c81b6
67 changed files with 334 additions and 479 deletions

View file

@ -6,7 +6,6 @@ package models
import (
"fmt"
"time"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util"
@ -26,14 +25,8 @@ const (
type Notice struct {
ID int64 `xorm:"pk autoincr"`
Type NoticeType
Description string `xorm:"TEXT"`
Created time.Time `xorm:"-"`
CreatedUnix int64 `xorm:"INDEX created"`
}
// AfterLoad is invoked from XORM after setting the values of all fields of this object.
func (n *Notice) AfterLoad() {
n.Created = time.Unix(n.CreatedUnix, 0).Local()
Description string `xorm:"TEXT"`
CreatedUnix util.TimeStamp `xorm:"INDEX created"`
}
// TrStr returns a translation format string.