Skip to content

Commit 36489b5

Browse files
don't use fixed (char*
1 parent 97df064 commit 36489b5

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

fCraft/Player/Player.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ public bool IsStaff {
155155
public string PortalWorld;
156156
public Position PortalTPPos;
157157
public string PortalName;
158-
public bool BuildingPortal = true;
159158
public DateTime LastUsedPortal;
160159
public DateTime LastWarnedPortal;
161160
public bool PortalsEnabled = true;

fCraft/Player/PlayerDB.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,22 @@ static void LoadInternal( StreamReader reader, string header ) {
220220
unsafe static void Split(string line, ref string[] fields, out int count) {
221221
// Effectively string.split(',') but without the two passes and memory allocations.
222222
count = 0;
223-
fixed (char* ptr = line) {
224-
int start = 0, len = 0;
225-
for (int i = 0; i < line.Length; i++) {
226-
if (ptr[i] != ',') { len++; continue; }
227-
if (count == fields.Length)
228-
Array.Resize(ref fields, count + 10);
229-
fields[count] = len == 0 ? "" : new String(ptr, start, len); count++;
230-
// Start next string at character after the ,
231-
start = i + 1;
232-
len = 0;
233-
}
234-
235-
// We will always have at least one string, even if it just empty.
223+
int start = 0, len = 0;
224+
for (int i = 0; i < line.Length; i++) {
225+
if (line[i] != ',') { len++; continue; }
236226
if (count == fields.Length)
237227
Array.Resize(ref fields, count + 10);
238-
fields[count] = len == 0 ? "" : new String(ptr, start, len); count++;
228+
229+
fields[count] = line.Substring(start, len); count++;
230+
// Start next string at character after the ,
231+
start = i + 1;
232+
len = 0;
239233
}
234+
235+
// We will always have at least one string, even if it just empty.
236+
if (count == fields.Length)
237+
Array.Resize(ref fields, count + 10);
238+
fields[count] = line.Substring(start, len); count++;
240239
}
241240

242241

0 commit comments

Comments
 (0)