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:
@@ -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]
|
||||
|
Reference in New Issue
Block a user