Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FixedBufferExtensions.cs
Go to the documentation of this file.
1
using
System.Runtime.InteropServices
;
2
3
namespace
System
;
4
5
internal
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
}
System.FixedBufferExtensions.FixedBufferEqualsString
static bool FixedBufferEqualsString(this ReadOnlySpan< char > span, string value)
Definition
FixedBufferExtensions.cs:25
System.FixedBufferExtensions.GetFixedBufferStringLength
static int GetFixedBufferStringLength(this ReadOnlySpan< char > span)
Definition
FixedBufferExtensions.cs:15
System.FixedBufferExtensions.GetStringFromFixedBuffer
static unsafe string GetStringFromFixedBuffer(this ReadOnlySpan< char > span)
Definition
FixedBufferExtensions.cs:7
System.FixedBufferExtensions
Definition
FixedBufferExtensions.cs:6
System.Runtime.InteropServices.MemoryMarshal
Definition
MemoryMarshal.cs:11
string
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.ExceptionArgument.value
@ value
System
Definition
BlockingCollection.cs:8
System.ReadOnlySpan.Length
int Length
Definition
ReadOnlySpan.cs:70
System.ReadOnlySpan
Definition
ReadOnlySpan.cs:14
source
System.Private.CoreLib
System
FixedBufferExtensions.cs
Generated by
1.10.0