Add ReferenceProperties for efficient reference tracking
Introduce a lazily-computed ReferenceProperties array to AcBinarySerializer, containing only complex and string properties. This enables efficient iteration and reference tracking during serialization by filtering relevant properties on first access.
This commit is contained in:
parent
e8a0d36e43
commit
a87dc37b8b
|
|
@ -55,6 +55,34 @@ public static partial class AcBinarySerializer
|
|||
/// </summary>
|
||||
private int[]? _metadataPropertyHashes;
|
||||
|
||||
/// <summary>
|
||||
/// Lazy-computed array of reference properties (complex types + strings).
|
||||
/// Used by scan pass to quickly iterate only properties that need reference tracking.
|
||||
/// </summary>
|
||||
private BinaryPropertyAccessor[]? _referenceProperties;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the array of reference properties (complex types + strings).
|
||||
/// Computed lazily on first access.
|
||||
/// </summary>
|
||||
public BinaryPropertyAccessor[] ReferenceProperties
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _referenceProperties ??= ComputeReferenceProperties();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private BinaryPropertyAccessor[] ComputeReferenceProperties()
|
||||
{
|
||||
var list = new List<BinaryPropertyAccessor>();
|
||||
foreach (var prop in Properties)
|
||||
{
|
||||
if (prop.IsComplexType || prop.AccessorType == PropertyAccessorType.String)
|
||||
list.Add(prop);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public int[] MetadataPropertyHashes
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue