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

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed Sep 7, 2017
1 parent 1cc6053 commit 502debe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public static void Pipe(this Transformation transformation, ReadOnlyBytes source
// TODO: "ReadOnlySpan<byte> remainder = stackalloc byte[0]" would fit better here,
// but it emits substandard IL, see https://github.com/dotnet/roslyn/issues/21952
//
// make 'remainder' formally stack-referring or we won't be able to reference stack data later
var remainder = true ? new ReadOnlySpan<byte>() : stackalloc byte[0];
// Assign 'remainder' to something formally stack-referring.
// The default classification is "returnable, not referring to stack", we want the opposite in this case.
ReadOnlySpan<byte> remainder = true ? new ReadOnlySpan<byte>() : stackalloc byte[0];
Span<byte> stackSpan = stackalloc byte[stackLength];

var poisition = Position.First;
Expand Down Expand Up @@ -325,10 +326,10 @@ internal static int IndexOfStraddling(this ReadOnlySpan<byte> first, IReadOnlyBu
if (bytesToSearchAgain.IndexOf(value[0]) != -1)
{
var combinedBufferLength = value.Length << 1;
Span<byte> combined = combinedBufferLength < 128 ?
var combined = combinedBufferLength < 128 ?
stackalloc byte[combinedBufferLength] :
// TODO (pri 3): I think this could be eliminated by chunking values
combined = new byte[combinedBufferLength];
(Span<byte>)new byte[combinedBufferLength];

bytesToSearchAgain.CopyTo(combined);
int combinedLength = bytesToSearchAgain.Length + rest.CopyTo(combined.Slice(bytesToSearchAgain.Length));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ public static string GetUtf8String(this ReadableBuffer buffer)
// TODO: "ReadOnlySpan<byte> textSpan = stackalloc byte[0]" would fit better here,
// but it emits substandard IL, see https://github.com/dotnet/roslyn/issues/21952
//
// make 'textSpan' formally stack-referring or we won't be able to reference stack data later
var textSpan = true? new ReadOnlySpan<byte>() : stackalloc byte[0];
// Assign 'textSpan' to something formally stack-referring.
// The default classification is "returnable, not referring to stack", we want the opposite in this case.
ReadOnlySpan<byte> textSpan = true? new ReadOnlySpan<byte>() : stackalloc byte[0];

if (buffer.IsSingleSpan)
{
Expand Down

0 comments on commit 502debe

Please sign in to comment.