Browse Source

Added more cases where value type copies are skipped

pull/44/head
Anairkoen Schno 4 years ago
parent
commit
d606c1c74d
2 changed files with 19 additions and 1 deletions
  1. +17
    -0
      IPA.Loader/Config/Stores/GeneratedStoreImpl/Correction.cs
  2. +2
    -1
      IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs

+ 17
- 0
IPA.Loader/Config/Stores/GeneratedStoreImpl/Correction.cs View File

@ -27,7 +27,13 @@ namespace IPA.Config.Stores
var expectType = GetExpectedValueTypeForType(memberType);
if (expectType == typeof(Map)) // TODO: make this slightly saner
{
if (expectType.IsValueType)
{ // custom value type
return ReadObjectMembers(memberType).Any(NeedsCorrection);
}
return true;
}
return false;
}
@ -86,6 +92,17 @@ namespace IPA.Config.Stores
var valueLocal = GetLocal(convType);
il.Emit(OpCodes.Stloc, valueLocal);
void LdlocaValueLocal(ILGenerator il)
=> il.Emit(OpCodes.Ldloca, valueLocal);
foreach (var mem in structure)
{
if (NeedsCorrection(mem))
EmitLoadCorrectStore(il, mem, shouldLock, alwaysNew, GetLocal,
LdlocaValueLocal, LdlocaValueLocal, parentobj);
}
il.Emit(OpCodes.Ldloc, valueLocal);
}
if (member.IsNullable)


+ 2
- 1
IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs View File

@ -124,7 +124,8 @@ namespace IPA.Config.Stores
foreach (var member in structure)
{
EmitLoadCorrectStore(il, member, false, true, GetLocal, GetMethodThis, GetMethodThis, GetMethodThis);
if (NeedsCorrection(member))
EmitLoadCorrectStore(il, member, false, true, GetLocal, GetMethodThis, GetMethodThis, GetMethodThis);
}
il.Emit(OpCodes.Pop);


Loading…
Cancel
Save