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

@ -36,6 +36,12 @@ namespace SourceGit.ViewModels
}
}
public string FullMessage
{
get => _fullMessage;
private set => SetProperty(ref _fullMessage, value);
}
public List<Models.Change> Changes
{
get => _changes;
@ -376,6 +382,7 @@ namespace SourceGit.ViewModels
private void Refresh()
{
_changes = null;
FullMessage = string.Empty;
VisibleChanges = null;
SelectedChanges = null;
@ -389,6 +396,7 @@ namespace SourceGit.ViewModels
Task.Run(() =>
{
var fullMessage = new Commands.QueryCommitFullMessage(_repo, _commit.SHA).Result();
var parent = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
var cmdChanges = new Commands.CompareRevisions(_repo, parent, _commit.SHA) { Cancel = _cancelToken };
var changes = cmdChanges.Result();
@ -407,6 +415,7 @@ namespace SourceGit.ViewModels
{
Dispatcher.UIThread.Post(() =>
{
FullMessage = fullMessage;
Changes = changes;
VisibleChanges = visible;
});
@ -444,6 +453,7 @@ namespace SourceGit.ViewModels
private string _repo = string.Empty;
private int _activePageIndex = 0;
private Models.Commit _commit = null;
private string _fullMessage = string.Empty;
private List<Models.Change> _changes = null;
private List<Models.Change> _visibleChanges = null;
private List<Models.Change> _selectedChanges = null;