1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

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,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]