Skip to content

[Question] Why not use unsafe code in order to eliminate bounds checking in IndexOf methods? #7696

@OnurGumus

Description

@OnurGumus

While I was checking https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs

I noticed that those IndexOf methods don't use any unsafe methods in order to prevent bounds checking of the arrays. While unsafe code is not recommended in general, though coreclr libraries are somewhat "trusted". I just wanted to ask why unsafe code is not used in those places.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions