Unrolled loops so the debugger works

This commit is contained in:
Samuele Lorefice
2025-02-25 18:27:37 +01:00
parent 91b74a24dd
commit 9081c9b32e

View File

@@ -98,16 +98,16 @@ public class Reader {
blockOffset += t.GetCustomAttribute<DNAClassAttribute>()!.Size;
}
}
objects.AsParallel().ForAll(x =>
{
FieldInfo[] fieldInfo = x.Value.GetType().GetFields();
fieldInfo.Where(fldInfo => fldInfo.GetCustomAttribute<DNAFieldAttribute>()!.IsPointer).ToList().ForEach(f =>
{
var addr = GetBlockFieldDataOffset(x.Key.Item1, f.GetCustomAttribute<DNAFieldAttribute>()!.OriginalIndex, fieldInfo);
var obj = objects.GetValueOrDefault((addr, f.FieldType));
if (obj != null) f.SetValue(x.Value, obj);
});
});
foreach (var obj in objects) {
FieldInfo[] fieldInfo = obj.Value.GetType().GetFields();
var list = fieldInfo.Where(fldInfo => fldInfo.GetCustomAttribute<DNAFieldAttribute>()!.IsPointer).ToList();
foreach(var f in list) {
var addr = GetBlockFieldDataOffset(obj.Key.Item1, f.GetCustomAttribute<DNAFieldAttribute>()!.OriginalIndex, fieldInfo);
var newobj = objects.GetValueOrDefault((addr, f.FieldType));
if (newobj != null) f.SetValue(obj.Value, newobj);
}
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -163,7 +163,6 @@ public class Reader {
if(value == null){ //if the data could not be converted
//Check if the field is a pointer to another DNA structure
//if (dnaTypes.Values.FirstOrDefault(x => x.GetCustomAttribute<DNAClassAttribute>()!.OriginalName == attrib.OriginalType) != null) {
if (dnaTypesDb.ContainsKey(attrib.OriginalType)) {
//Create a new instance of the DNA structure type
object? newObj = ActivateInstance(attrib.OriginalType);