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

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyKuhne committed Jan 15, 2019
1 parent 36b4ebb commit 69c6f4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public unsafe void Append(char* value, int length)
_pos += length;
}

public unsafe void Append(ReadOnlySpan<char> value)
public void Append(ReadOnlySpan<char> value)
{
int pos = _pos;
if (pos > _chars.Length - value.Length)
Expand Down
14 changes: 3 additions & 11 deletions src/System.Text.ValueBuilder/System/Variant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,17 @@ public unsafe bool TryGetValue<T>(out T value) where T : unmanaged
|| (typeof(T) == typeof(uint) && Type == VariantType.UInt32)
|| (typeof(T) == typeof(ulong) && Type == VariantType.UInt64))
{
// The JIT is able to generate more efficient code when including the
// code for CastTo<T>() directly.
fixed (void* u = &_union)
{
value = *(T*)u;
}
value = CastTo<T>();
success = true;
}

return success;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe T CastTo<T>() where T : unmanaged
private T CastTo<T>() where T : unmanaged
{
fixed (void* u = &_union)
{
return *(T*)u;
}
return Unsafe.As<Union, T>(ref Unsafe.AsRef(_union));
}

// We have explicit constructors for each of the supported types for performance
Expand Down

0 comments on commit 69c6f4a

Please sign in to comment.