Skip to content

Reduce enumerator boxing in ProjectElementContainer #11808

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

Merged
merged 1 commit into from
May 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Build/Construction/ProjectElementContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,9 @@ public bool Remove(T item)
return false;
}

public IEnumerator<T> GetEnumerator() => new Enumerator(_initial, _forwards);
public Enumerator GetEnumerator() => new Enumerator(_initial, _forwards);

IEnumerator<T> IEnumerable<T>.GetEnumerator() => GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

Expand Down Expand Up @@ -948,13 +950,18 @@ internal ProjectElementSiblingEnumerable(ProjectElement initial, bool forwards =
/// <summary>
/// Get enumerator
/// </summary>
public readonly IEnumerator<ProjectElement> GetEnumerator() => _enumerator;
public readonly Enumerator GetEnumerator() => _enumerator;

/// <summary>
/// Get non generic enumerator
/// </summary>
IEnumerator IEnumerable.GetEnumerator() => _enumerator;

/// <summary>
/// Get enumerator
/// </summary>
IEnumerator<ProjectElement> IEnumerable<ProjectElement>.GetEnumerator() => _enumerator;

/// <summary>
/// Enumerator over a series of sibling ProjectElement objects
/// </summary>
Expand Down