Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple enumeration #4682

Merged
merged 8 commits into from Mar 22, 2018
Merged

Conversation

drewnoakes
Copy link
Member

Changes proposed in this pull request:

  • Fix a few multiple-enumeration issues
  • Use IReadOnlyList<T> across all of GitModule and places that then must change in response to that

As mentioned elsewhere, this PR explores broader use of IReadOnlyList<T>. Currently quite a lot of data is passed around as the modifiable IList<T> which makes sense given GE has been around for longer than the comparatively new IReadOnlyList<T>. However IList<T> leaves you wondering, is it safe to modify this collection?

Before this PR there were 140 instances of "IList<" between GitCommands and GitUI projects. After, there are 56.

Interested in thoughts on this direction before going after the last instances.

What did I do to test the code and ensure quality:

  • Manual testing
  • Unit tests

Has been tested on:

  • GIT 2.16
  • Windows 10

@codecov
Copy link

codecov bot commented Mar 20, 2018

Codecov Report

Merging #4682 into master will decrease coverage by 0.01%.
The diff coverage is 31.09%.

@@            Coverage Diff             @@
##           master    #4682      +/-   ##
==========================================
- Coverage   27.57%   27.55%   -0.02%     
==========================================
  Files         508      508              
  Lines       40989    40992       +3     
  Branches     5965     5977      +12     
==========================================
- Hits        11301    11296       -5     
- Misses      29179    29185       +6     
- Partials      509      511       +2
Impacted Files Coverage Δ
GitUI/RevisionDiffInfoProvider.cs 73.46% <ø> (ø) ⬆️
GitUI/GitUICommands.cs 0% <ø> (ø) ⬆️
GitUI/GitUIExtensions.cs 0% <ø> (ø) ⬆️
GitUI/UserControls/BlameControl.cs 13% <ø> (ø) ⬆️
...serControls/ToolStripClasses/CommitIconProvider.cs 100% <ø> (ø) ⬆️
GitCommands/CommitDataManager.cs 42.37% <ø> (ø) ⬆️
GitUI/UserControls/PatchGrid.cs 23.07% <ø> (ø) ⬆️
...ExternalLinks/ConfiguredLinkDefinitionsProvider.cs 100% <ø> (ø) ⬆️
GitCommands/Settings/ConfigFileSettings.cs 40.35% <ø> (ø) ⬆️
...itUI/UserControls/RevisionGridClasses/DvcsGraph.cs 24.05% <ø> (ø) ⬆️
... and 49 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b03edb8...3457cf2. Read the comment docs.

@RussKie RussKie added this to the 3.00 milestone Mar 20, 2018
@RussKie RussKie added the ready label Mar 21, 2018
If implementation of IEnumerable<T> also implements ICollection<T> or
ICollection, then the corresponding Count property can be used directly,
avoiding enumeration.
Removed most occurrences of IList.
Remaining ones cannot easily be removed.
The values were cached, but in a presentation that didn't suit their usage.
This change stores them at the type they need to be.
Nest methods.
@drewnoakes
Copy link
Member Author

Went through and addressed most of the remaining IList<T> instances.

IList<GitRevision> items = new List<GitRevision> { _headRevision, baseCommit };
var items = new List<GitRevision> { _headRevision, baseCommit };

// TODO this can never be true
Copy link
Member

Choose a reason for hiding this comment

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

Remove this in separate commit?

@@ -69,6 +65,53 @@ public void Initialize(bool remote, string[] containRevisons)
{
Branches.Text = null;
}

Copy link
Member

Choose a reason for hiding this comment

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

return; here for clarity?

@RussKie RussKie merged commit 6d46a34 into gitextensions:master Mar 22, 2018
@RussKie RussKie removed the ready label Mar 22, 2018
@drewnoakes drewnoakes deleted the multiple-enumeration branch March 22, 2018 08:23
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.

None yet

3 participants