Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FixedBufferExtensions.cs
Go to the documentation of this file.
2
3namespace System;
4
5internal static class FixedBufferExtensions
6{
7 internal unsafe static string GetStringFromFixedBuffer(this ReadOnlySpan<char> span)
8 {
9 fixed (char* value = &MemoryMarshal.GetReference(span))
10 {
11 return new string(value, 0, span.GetFixedBufferStringLength());
12 }
13 }
14
15 internal static int GetFixedBufferStringLength(this ReadOnlySpan<char> span)
16 {
17 int num = span.IndexOf('\0');
18 if (num >= 0)
19 {
20 return num;
21 }
22 return span.Length;
23 }
24
25 internal static bool FixedBufferEqualsString(this ReadOnlySpan<char> span, string value)
26 {
27 if (value == null || value.Length > span.Length)
28 {
29 return false;
30 }
31 int i;
32 for (i = 0; i < value.Length; i++)
33 {
34 if (value[i] == '\0' || value[i] != span[i])
35 {
36 return false;
37 }
38 }
39 if (i != span.Length)
40 {
41 return span[i] == '\0';
42 }
43 return true;
44 }
45}
static bool FixedBufferEqualsString(this ReadOnlySpan< char > span, string value)
static int GetFixedBufferStringLength(this ReadOnlySpan< char > span)
static unsafe string GetStringFromFixedBuffer(this ReadOnlySpan< char > span)