fix(core): Adds SkipLocalsInitAttribute support, optimizes broadcasted packets (#363)

- [X] Adds support for `SkipLocalsInitAttribute`. SkipLocalsInitAttribute skips initializing stack variables including `stackalloc`. I don't think it is wired/working yet but should be implemented soon.
- [X] Optimizes broadcasted packets by checking if the first byte (packet ID) is non-zero. If it is already set, it reuses the buffer.
- [X] Removes unnecessary refs to Spans. I don't think the Span struct itself is mutable, so a ref is not helpful.
This commit is contained in:
Kamron Batman 2020-12-26 12:46:06 -08:00 committed by GitHub
parent 9c9591b098
commit 03d0a4664e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 478 additions and 285 deletions

View file

@ -40,7 +40,7 @@ namespace Benchmarks
}
public static int CreateUnicodeMessage(
ref Span<byte> buffer,
Span<byte> buffer,
Serial serial, int graphic, MessageType type, int hue, int font, string lang, string name, string text
)
{
@ -116,8 +116,7 @@ namespace Benchmarks
Span<byte> buffer = result.Buffer[0];
var length = CreateUnicodeMessage(
ref buffer,
Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
buffer, Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
);
pipe.Writer.Advance((uint)length);
}
@ -131,8 +130,7 @@ namespace Benchmarks
var text = "This is some really long text that we want to handle. It should take a little bit to encode this.";
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
var length = CreateUnicodeMessage(
ref buffer,
Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
buffer, Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
);
buffer = buffer.Slice(0, length);
@ -151,8 +149,7 @@ namespace Benchmarks
{
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)];
var length = CreateUnicodeMessage(
ref buffer,
Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
buffer, Serial.MinusOne, -1, MessageType.Regular, 0x3B2, 3, "ENU", "System", text
);
buffer = buffer.Slice(0, length);