mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
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:
parent
6426da3289
commit
9e45a8a77d
12 changed files with 67 additions and 65 deletions
|
@ -12,31 +12,13 @@ namespace SourceGit.Models
|
|||
public ulong AuthorTime { get; set; } = 0;
|
||||
public User Committer { get; set; } = User.Invalid;
|
||||
public ulong CommitterTime { get; set; } = 0;
|
||||
public string Body { get; set; } = string.Empty;
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
public List<string> Parents { get; set; } = new List<string>();
|
||||
public List<Decorator> Decorators { get; set; } = new List<Decorator>();
|
||||
public bool HasDecorators => Decorators.Count > 0;
|
||||
public bool IsMerged { get; set; } = false;
|
||||
public Thickness Margin { get; set; } = new Thickness(0);
|
||||
|
||||
public string Subject
|
||||
{
|
||||
get
|
||||
{
|
||||
var end = Body.IndexOf("\r\n\r\n", StringComparison.Ordinal);
|
||||
if (end == -1)
|
||||
{
|
||||
end = Body.IndexOf("\n\n", StringComparison.Ordinal);
|
||||
if (end > 0)
|
||||
return Body.Substring(0, end).Replace("\n", "", StringComparison.Ordinal);
|
||||
|
||||
return Body.Replace("\n", " ", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
return Body.Substring(0, end).Replace("\r\n", " ", StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
public string AuthorTimeStr => _utcStart.AddSeconds(AuthorTime).ToString("yyyy/MM/dd HH:mm:ss");
|
||||
public string CommitterTimeStr => _utcStart.AddSeconds(CommitterTime).ToString("yyyy/MM/dd HH:mm:ss");
|
||||
public string AuthorTimeShortStr => _utcStart.AddSeconds(AuthorTime).ToString("yyyy/MM/dd");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue