-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemporaryString.cs
More file actions
41 lines (38 loc) · 1.05 KB
/
TemporaryString.cs
File metadata and controls
41 lines (38 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
namespace JsonParser
{
public struct TemporaryString
{
private char[] _chars;
private string _charString;
private readonly int _length;
public TemporaryString(int length)
{
_charString = new string('\0', length);
_chars = new char[length];
_length = length;
}
public string GetString(JsonParser.JsonValue value)
{
unsafe
{
fixed (char* c = _chars)
{
for (var i = 0; i < _length; i++)
{
c[i] = '\0';
}
value.CopyTo(_chars);
fixed (char* s = _charString)
{
for (var i = 0; i < _length; i++)
{
s[i] = c[i];
}
}
}
}
return _charString;
}
}
}