Skip to content

Could SortedSet.InOrderTreeWalk use recursion instead of allocating? #18769

Closed
@jamesqo

Description

@jamesqo

SortedSet.InOrderTreeWalk currently uses a stack on which the nodes to walk are pushed/popped: https://github.com/dotnet/corefx/blob/master/src/System.Collections/src/System/Collections/Generic/SortedSet.cs#L234

It looks like it would be possible to implement this recursively instead, i.e. InOrderTreeWalk(left); action(current); InOrderTreeWalk(right) and eliminate the Stack allocation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.CollectionsenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions