-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed temporary array allocations for properties (#1948)
* Removed temporary array allocations for cases with the small number of log event properties * Added test to ensure that null array does not break message template parameters binding * Excluded ILogger.Write<T1, ...> methods from method body comparison test.
- Loading branch information
Showing
6 changed files
with
168 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#if FEATURE_SPAN | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Serilog.Core; | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
struct PropertiesInlineArray | ||
{ | ||
object? Object1; | ||
object? Object2; | ||
object? Object3; | ||
|
||
public Span<object?> AsSpan(int count) | ||
{ | ||
if (count is < 0 or > 3) | ||
ThrowArgumentOutOfRangeException(nameof(count)); | ||
|
||
return MemoryMarshal.CreateSpan(ref Object1, count); | ||
} | ||
|
||
[DoesNotReturn] | ||
static void ThrowArgumentOutOfRangeException(string param) | ||
{ | ||
throw new ArgumentOutOfRangeException(param); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters