Refactored mangling function

Utilizes a string builder instead of shitty String.Concat trickery
This commit is contained in:
arookas 2016-02-01 15:50:46 -05:00
parent 1d324baf9d
commit db6739be42

View file

@ -216,18 +216,18 @@ namespace arookas {
// static util
string MangleSymbolName(string basename, bool system, bool local) {
var prefix = "";
var suffix = "";
if (system) {
prefix = "$";
}
if (local) {
suffix = String.Format("@{0}", mLocalStack.Peek());
}
if (prefix == "" && suffix == "") {
if (!system && !local) {
return basename;
}
return String.Concat(prefix, basename, suffix);
var sb = new StringBuilder(basename.Length + 16);
if (system) {
sb.Append('$');
}
sb.Append(basename);
if (local) {
sb.AppendFormat("@{0}", mLocalStack.Peek());
}
return sb.ToString();
}
}
}