Rename some variables in MiniYaml.cs for readability

This commit is contained in:
Taryn Hill
2015-11-11 12:44:04 -06:00
parent d33922915e
commit 9b568f53a1

View File

@@ -160,15 +160,15 @@ namespace OpenRA
line = line.Substring(0, commentIndex).TrimEnd(' ', '\t'); line = line.Substring(0, commentIndex).TrimEnd(' ', '\t');
if (line.Length == 0) if (line.Length == 0)
continue; continue;
var cp = 0; var charPosition = 0;
var level = 0; var level = 0;
var spaces = 0; var spaces = 0;
var textStart = false; var textStart = false;
var c = line[cp]; var currChar = line[charPosition];
while (!(c == '\n' || c == '\r') && cp < line.Length && !textStart) while (!(currChar == '\n' || currChar == '\r') && charPosition < line.Length && !textStart)
{ {
c = line[cp]; currChar = line[charPosition];
switch (c) switch (currChar)
{ {
case ' ': case ' ':
spaces++; spaces++;
@@ -178,11 +178,11 @@ namespace OpenRA
level++; level++;
} }
cp++; charPosition++;
break; break;
case '\t': case '\t':
level++; level++;
cp++; charPosition++;
break; break;
default: default:
textStart = true; textStart = true;
@@ -190,8 +190,8 @@ namespace OpenRA
} }
} }
var t = line.Substring(cp); var realText = line.Substring(charPosition);
if (t.Length == 0) if (realText.Length == 0)
continue; continue;
var location = new MiniYamlNode.SourceLocation { Filename = filename, Line = lineNo }; var location = new MiniYamlNode.SourceLocation { Filename = filename, Line = lineNo };
@@ -201,8 +201,8 @@ namespace OpenRA
levels.RemoveAt(levels.Count - 1); levels.RemoveAt(levels.Count - 1);
var d = new List<MiniYamlNode>(); var d = new List<MiniYamlNode>();
var rhs = SplitAtColon(ref t); var rhs = SplitAtColon(ref realText);
levels[level].Add(new MiniYamlNode(t, rhs, d, location)); levels[level].Add(new MiniYamlNode(realText, rhs, d, location));
levels.Add(d); levels.Add(d);
} }
@@ -210,15 +210,15 @@ namespace OpenRA
return levels[0]; return levels[0];
} }
static string SplitAtColon(ref string t) static string SplitAtColon(ref string realText)
{ {
var colon = t.IndexOf(':'); var colon = realText.IndexOf(':');
if (colon == -1) if (colon == -1)
return null; return null;
var ret = t.Substring(colon + 1).Trim(); var ret = realText.Substring(colon + 1).Trim();
if (ret.Length == 0) if (ret.Length == 0)
ret = null; ret = null;
t = t.Substring(0, colon).Trim(); realText = realText.Substring(0, colon).Trim();
return ret; return ret;
} }