Skip to content

Clean up HashSet.cs copy #7340

Open
Open

Description

@danmoseley

We have a partial copy of HashSet as it existed in the .NET Framework circa 2008 or something, with the following comment:

==================================================================================================================
MSBUILD COMMENT:
Ripped off from Hashset.cs with the following changes:
* class renamed
* unnecessary methods and attributes if-deffed out (code retained to help windiff, but indented)
* require T implements IKeyed, and accept IKeyed directly where necessary
* all constructors require a comparer -- an IEqualityComparer<IKeyed> -- to avoid mistakes
* change Contains to give you back the found entry, rather than a boolean
* change Add so that it always adds, even if there's an entry already present with the same name.
We want "replacement" semantics, like a dictionary keyed on name.
* constructor that allows the collection to be read-only
* implement IDictionary<string, T>
* some convenience methods taking 'string' as overloads of methods taking IKeyed
Other than this it is modified absolutely minimally to make it easy to diff with the originals (in the Originals folder)
to verify that no errors were introduced, and make it easier to possibly pick up any future bug fixes to the original.
The care taken to minimally modify this means that it is not necessary to carefully code review this complex class,
nor unit test it directly.
==================================================================================================================

The rationale for this odd pattern of fragmented dead code was to diff for future updates to HashSet -- but the live copy of HashSet here has since changed so substantially that it can likely hardly be diffed at all.

As a matter of healthy cleanup, I suggest to delete all the dead code.

There have also been several improvements to HashSet since the copy was done, for perf reasons - either obvious ones or to produce better codegen. It would be nice to copy them (again, without bringing dead code) for some small perf wins. I expect this will be fairly easy to do by eyeballing them side by side.

Activity

  1. added
    needs-triage
    on Jan 26, 2022
  2. elachlan commented on Jan 27, 2022

    @elachlan
    Contributor

    I have been attempting this. The CORE version was re-written in June of 2020. I think it might be best to take that version and refactor it with the changes from MSBUILD.

    I will let you know how I go.

  3. rainersigwald commented on Jan 27, 2022

    @rainersigwald
    Member

    I wouldn't spend a lot of time on this: we don't have any indication that the current implementation is causing a bottleneck today, and changes are likely to be hard to review due to the overall complexity of the class.

  4. removed
    needs-triage
    on Jan 27, 2022
  5. added this to the Backlog milestone on Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions