Skip to content

Resolve differences between string.IndexOfAny and MemoryExtensions.IndexOfAny #60864

Closed

Description

@stephentoub

For a number of values <= 5, string.IndexOfAny just delegates to MemoryExtensions.IndexOfAny. But for values length > 5, it implements a "probabilistic map" (basically a Bloom filter) that it uses when walking each element of the input to determine whether it's likely in the set, and then does the actual comparison against the set only for the likely ones. In contrast, for values length > 5, MemoryExtensions.IndexOfAny walks each character in the input, and for each walks each of the values to see if they match.

There's little reason these should be different. We should decide on and pick the better strategy (or an even better one if such a thing exists), use it in MemoryExtensions.IndexOfAny, and then have the string.IndexOfAny just unconditionally delegate to MemoryExtensions.

cc: @GrabYourPitchforks

Activity

  1. added this to the 7.0.0 milestone on Oct 26, 2021
  2. ghost added
    untriaged
    on Oct 26, 2021
  3. removed
    untriaged
    on Oct 28, 2021
  4. self-assigned this
    on Jan 14, 2022
  5. ghost added
    in-pr
    on Jan 14, 2022
  6. ghost removed
    in-pr
    on Jan 16, 2022
  7. ghost locked as resolved and limited conversation to collaborators on Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Runtimetenet-performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions