Skip to content

Conversation

mstv
Copy link
Member

@mstv mstv commented Oct 30, 2023

Proposed changes

Remove redundant field RevisionGraphRevision._parents, use _startSegments instead.
The affected property Parents is only used for getting tooltip information and for tests.

Screenshots

N/A

Test methodology

  • existing tests

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@@ -94,7 +94,7 @@ public int EnsureScoreIsAbove(int minimalScore)

public ObjectId Objectid { get; }

public ImmutableStack<RevisionGraphRevision> Parents => _parents;
public IEnumerable<RevisionGraphRevision> Parents => _startSegments.Select(segment => segment.Parent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_parents is ImmutableStack, _segments is ConcurrentQueue
But revisions are only updated from one thread, so it is probably OK.
ToArray() creates a snapshot, so it issafer.
Reading Parents in BranchFinder is not critical for performance, foreach in EnsureScoreIsAbove() is to some extent.
There is a lock issue still somewhere, why refresh is not running. I just want to avoid more issues...
But approving without requesting changes.

Suggested change
public IEnumerable<RevisionGraphRevision> Parents => _startSegments.Select(segment => segment.Parent);
public IEnumerable<RevisionGraphRevision> Parents => _startSegments.ToArray().Select(segment => segment.Parent);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who needs the safety of a snapshot, can call
public RevisionGraphSegment[] GetStartSegments() => _startSegments.ToArray();

@mstv mstv merged commit f2f8f98 into gitextensions:master Oct 31, 2023
@mstv mstv deleted the optimize_graph branch October 31, 2023 21:03
@ghost ghost added this to the vNext milestone Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants