enhance: only store subject in commits.

It has several advantages:

* reduce the memory costed by histories
* higher performance while parsing commits
* no need to calculate subject every time, which is invoked most frequently to render histories
This commit is contained in:
leo 2024-06-08 12:19:48 +08:00
parent 6426da3289
commit 9e45a8a77d
12 changed files with 67 additions and 65 deletions

View file

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
@ -21,14 +22,16 @@ namespace SourceGit.ViewModels
public Reword(Repository repo, Models.Commit head)
{
_repo = repo;
_oldMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, head.SHA).Result();
_message = _oldMessage;
Head = head;
Message = head.Body;
View = new Views.Reword() { DataContext = this };
}
public override Task<bool> Sure()
{
if (_message == Head.Body)
if (string.Compare(_message, _oldMessage, StringComparison.Ordinal) == 0)
return null;
_repo.SetWatcherEnabled(false);
@ -44,5 +47,6 @@ namespace SourceGit.ViewModels
private readonly Repository _repo = null;
private string _message = string.Empty;
private string _oldMessage = string.Empty;
}
}