summaryrefslogtreecommitdiffstats
path: root/models/repo_unit.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-12-11 12:37:04 +0800
committerLauris BH <lauris@nix.lv>2017-12-11 06:37:04 +0200
commitf2e20c81b66e6a937ecdb686f8d1011371433365 (patch)
tree490e5af82aefdd25de5d90225b083ecb3ed11e5f /models/repo_unit.go
parentc082c3bce35d6d5d829a1e516b9bbf45b6d49bdc (diff)
downloadgitea-f2e20c81b66e6a937ecdb686f8d1011371433365.tar.gz
gitea-f2e20c81b66e6a937ecdb686f8d1011371433365.zip
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
Diffstat (limited to 'models/repo_unit.go')
-rw-r--r--models/repo_unit.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/models/repo_unit.go b/models/repo_unit.go
index 3f0e65f9ab..5100ca1ce2 100644
--- a/models/repo_unit.go
+++ b/models/repo_unit.go
@@ -6,7 +6,8 @@ package models
import (
"encoding/json"
- "time"
+
+ "code.gitea.io/gitea/modules/util"
"github.com/Unknwon/com"
"github.com/go-xorm/core"
@@ -19,8 +20,7 @@ type RepoUnit struct {
RepoID int64 `xorm:"INDEX(s)"`
Type UnitType `xorm:"INDEX(s)"`
Config core.Conversion `xorm:"TEXT"`
- CreatedUnix int64 `xorm:"INDEX CREATED"`
- Created time.Time `xorm:"-"`
+ CreatedUnix util.TimeStamp `xorm:"INDEX CREATED"`
}
// UnitConfig describes common unit config
@@ -105,11 +105,6 @@ func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) {
}
}
-// AfterLoad is invoked from XORM after setting the values of all fields of this object.
-func (r *RepoUnit) AfterLoad() {
- r.Created = time.Unix(r.CreatedUnix, 0).Local()
-}
-
// Unit returns Unit
func (r *RepoUnit) Unit() Unit {
return Units[r.Type]