mirror of
https://github.com/Wack0/IFPSTools.NET.git
synced 2025-06-18 18:55:42 -04:00
lib: use single static cultureinfo instead of allocating every time
This commit is contained in:
parent
056cd7a9a1
commit
0f6e7a5bcb
@ -17,6 +17,7 @@ namespace IFPSLib
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class TypedData
|
public class TypedData
|
||||||
{
|
{
|
||||||
|
private static readonly CultureInfo s_Culture = new CultureInfo("en");
|
||||||
public IType Type { get; }
|
public IType Type { get; }
|
||||||
public object Value { get; }
|
public object Value { get; }
|
||||||
|
|
||||||
@ -129,11 +130,11 @@ namespace IFPSLib
|
|||||||
return new TypedData(type, br.Read<double>());
|
return new TypedData(type, br.Read<double>());
|
||||||
case PascalTypeCode.Extended:
|
case PascalTypeCode.Extended:
|
||||||
{
|
{
|
||||||
// BUGBUG: there must be something beter than this... but for now, it'll do
|
// BUGBUG: there must be something better than this... but for now, it'll do
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
ExtF80.PrintFloat80(sb, br.Read<ExtF80>(), PrintFloatFormat.ScientificFormat, 19);
|
ExtF80.PrintFloat80(sb, br.Read<ExtF80>(), PrintFloatFormat.ScientificFormat, 19);
|
||||||
TrimDecimalString(sb);
|
TrimDecimalString(sb);
|
||||||
return new TypedData(type, decimal.Parse(sb.ToString(), System.Globalization.NumberStyles.Float, new CultureInfo("en")));
|
return new TypedData(type, decimal.Parse(sb.ToString(), NumberStyles.Float, s_Culture));
|
||||||
}
|
}
|
||||||
|
|
||||||
case PascalTypeCode.Currency:
|
case PascalTypeCode.Currency:
|
||||||
@ -208,7 +209,7 @@ namespace IFPSLib
|
|||||||
WriteValue<double>(bw);
|
WriteValue<double>(bw);
|
||||||
break;
|
break;
|
||||||
case PascalTypeCode.Extended:
|
case PascalTypeCode.Extended:
|
||||||
if (!ExtF80.TryParse(ValueAs<decimal>().ToString(new CultureInfo("en")), out var extf))
|
if (!ExtF80.TryParse(ValueAs<decimal>().ToString(s_Culture), out var extf))
|
||||||
throw new ArgumentOutOfRangeException("Value {0} cannot fit into an 80-bit floating point number");
|
throw new ArgumentOutOfRangeException("Value {0} cannot fit into an 80-bit floating point number");
|
||||||
bw.Write(extf);
|
bw.Write(extf);
|
||||||
break;
|
break;
|
||||||
@ -343,7 +344,7 @@ namespace IFPSLib
|
|||||||
sb.Append(')');
|
sb.Append(')');
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
return string.Format("{0}({1})", Type.Name, Value);
|
return string.Format(s_Culture, "{0}({1})", Type.Name, Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user