[PR #3142] [MERGED] Refactor struct's time to remove unnecessary memory usage #16792

Closed
opened 2025-11-02 12:19:13 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/3142
Author: @lunny
Created: 12/11/2017
Status: Merged
Merged: 12/11/2017
Merged by: @lafriks

Base: masterHead: lunny/improve_time


📝 Commits (6)

  • c21c823 refactor struct's time to remove unnecessary memory usage
  • 4732388 use AsTimePtr simple code
  • 2382f01 fix tests
  • a384f9e fix time compare
  • 8db9038 fix template on gpg
  • 86814ab use AddDuration instead of Add

📊 Changes

67 files changed (+334 additions, -479 deletions)

View changed files

📝 models/action.go (+5 -10)
📝 models/admin.go (+2 -9)
📝 models/attachment.go (+3 -10)
📝 models/branches.go (+11 -19)
📝 models/gpg_key.go (+14 -22)
📝 models/gpg_key_test.go (+4 -2)
📝 models/issue.go (+6 -23)
📝 models/issue_comment.go (+5 -10)
📝 models/issue_comment_test.go (+2 -2)
📝 models/issue_milestone.go (+11 -20)
📝 models/issue_milestone_test.go (+3 -2)
📝 models/issue_reaction.go (+8 -14)
📝 models/issue_stopwatch.go (+7 -18)
📝 models/issue_stopwatch_test.go (+3 -2)
📝 models/issue_test.go (+1 -1)
📝 models/issue_watch.go (+7 -33)
📝 models/lfs.go (+8 -13)
📝 models/login_source.go (+3 -11)
📝 models/notification.go (+5 -27)
📝 models/pull.go (+12 -27)

...and 47 more files

📄 Description

This PR will remove unnecessary time.Time on almost all the structs and define a new time type TimeStamp int64 to handle the time. It's also improve the TimeSince where converted to time.Time and convert back before. So that, many BeforeInsert and AfterLoad is still unnecessary. The code is more clean.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/3142 **Author:** [@lunny](https://github.com/lunny) **Created:** 12/11/2017 **Status:** ✅ Merged **Merged:** 12/11/2017 **Merged by:** [@lafriks](https://github.com/lafriks) **Base:** `master` ← **Head:** `lunny/improve_time` --- ### 📝 Commits (6) - [`c21c823`](https://github.com/go-gitea/gitea/commit/c21c823677f30a98505a3972f830ee0e368ca34c) refactor struct's time to remove unnecessary memory usage - [`4732388`](https://github.com/go-gitea/gitea/commit/473238893ceb9cb1ec9a5bd6f8cc573a4dac6ea6) use AsTimePtr simple code - [`2382f01`](https://github.com/go-gitea/gitea/commit/2382f01ebe946092fc45a6f0278bcf8572d9e5b4) fix tests - [`a384f9e`](https://github.com/go-gitea/gitea/commit/a384f9e5ad897a061b8a2303b01ead1a6bdf4436) fix time compare - [`8db9038`](https://github.com/go-gitea/gitea/commit/8db90383639ef17e7e8c8653e5e9895161a51871) fix template on gpg - [`86814ab`](https://github.com/go-gitea/gitea/commit/86814abfeaa7b19f3290efff9903be95fcfa5e7a) use AddDuration instead of Add ### 📊 Changes **67 files changed** (+334 additions, -479 deletions) <details> <summary>View changed files</summary> 📝 `models/action.go` (+5 -10) 📝 `models/admin.go` (+2 -9) 📝 `models/attachment.go` (+3 -10) 📝 `models/branches.go` (+11 -19) 📝 `models/gpg_key.go` (+14 -22) 📝 `models/gpg_key_test.go` (+4 -2) 📝 `models/issue.go` (+6 -23) 📝 `models/issue_comment.go` (+5 -10) 📝 `models/issue_comment_test.go` (+2 -2) 📝 `models/issue_milestone.go` (+11 -20) 📝 `models/issue_milestone_test.go` (+3 -2) 📝 `models/issue_reaction.go` (+8 -14) 📝 `models/issue_stopwatch.go` (+7 -18) 📝 `models/issue_stopwatch_test.go` (+3 -2) 📝 `models/issue_test.go` (+1 -1) 📝 `models/issue_watch.go` (+7 -33) 📝 `models/lfs.go` (+8 -13) 📝 `models/login_source.go` (+3 -11) 📝 `models/notification.go` (+5 -27) 📝 `models/pull.go` (+12 -27) _...and 47 more files_ </details> ### 📄 Description This PR will remove unnecessary time.Time on almost all the structs and define a new time `type TimeStamp int64` to handle the time. It's also improve the `TimeSince` where converted to `time.Time` and convert back before. So that, many `BeforeInsert` and `AfterLoad` is still unnecessary. The code is more clean. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:19:13 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#16792