Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AsSpan/AsMemory (start, length) #45310

Merged
merged 3 commits into from
Nov 30, 2020
Merged

Conversation

xtqqczze
Copy link
Contributor

  • Replace AsSpan().Slice(start, length) with AsSpan(start, length)
  • Replace AsMemory().Slice(start, length) with AsMemory(start, length)

Replace `AsSpan().Slice(start, length)` with `AsSpan(start, length)`
Replace `AsMemory().Slice(start, length)` with `AsMemory(start, length)`
Copy link
Member

@GrabYourPitchforks GrabYourPitchforks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I'd suggest not making changes to unit test files, as we could inadvertently bypass legitimate tests. In the case of AsSpan.cs, there are unit tests that validate that AsSpan().Slice(...) and AsSpan(...) have the same result, and doing a search-and-replace of these patterns will end up essentially removing the value that such tests would've given us.

That said, it looks like in the case of GuidArrayAsSpanWithStartAndLength the test actually did intend to test AsSpan(...) instead of AsSpan().Slice(...), if we're following the same pattern used by the other tests whose names end in the suffix *AsSpanWithStartAndLength.

But in the future please try to limit these changes to non-test code. Thanks!

@stephentoub stephentoub merged commit 1edc35f into dotnet:master Nov 30, 2020
@xtqqczze
Copy link
Contributor Author

In the case of AsSpan.cs, there are unit tests that validate that AsSpan().Slice(...) and AsSpan(...) have the same result, and doing a search-and-replace of these patterns will end up essentially removing the value that such tests would've given us.

@GrabYourPitchforks These tests were not part of the merged changes?

@xtqqczze
Copy link
Contributor Author

But in the future please try to limit these changes to non-test code. Thanks!

Yeah I did think twice about making these changes to tests, but in the case of GuidArrayAsSpanWithStartAndLength and others, they made sense.

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

Successfully merging this pull request may close these issues.

5 participants