Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Span.StartsWith(ReadOnlySpan<T>|ReadOnlySpan<byte>) #1294

Closed
ahsonkhan opened this issue Mar 10, 2017 · 3 comments
Closed

Span.StartsWith(ReadOnlySpan<T>|ReadOnlySpan<byte>) #1294

ahsonkhan opened this issue Mar 10, 2017 · 3 comments

Comments

@ahsonkhan
Copy link
Member

  1. Is StartsWith in the right place? i.e. on Span or extension methods
  2. Do we have the right StartsWith, i.e. over T or over byte?
  3. Is it efficiently implemented?
  4. Should StartsWith have an overload that takes an index?
@jkotas
Copy link
Member

jkotas commented Mar 10, 2017

Is it efficiently implemented?

It is not because of it depends on SequenceEquals in corefx that is not very efficient. Making Starts with efficient is really about making SequenceEquals efficient.

Should StartsWith have an overload that takes an index?

I do not think so (at least - not for performance reasons).

@davidfowl
Copy link
Member

Do we even need StartsWith? Is there a T[] equivalent?

@ahsonkhan
Copy link
Member Author

ahsonkhan commented Apr 1, 2017

StartsWith was added as part of dotnet/corefx#17322 (API reviewed here https://github.com/dotnet/corefx/issues/17414)

  1. It is an extension method on Span
  2. There are overloads for byte and T
  3. SequenceEqual has been improved using vectors (Span performance improvements corefx#17029)
  4. No, as per @jkotas comments.

Hence, closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants