diff --git a/AyCode.Core/Serializers/Binaries/AcBinarySerializer.BinarySerializeTypeMetadata.cs b/AyCode.Core/Serializers/Binaries/AcBinarySerializer.BinarySerializeTypeMetadata.cs index ab10cbc..d9c5775 100644 --- a/AyCode.Core/Serializers/Binaries/AcBinarySerializer.BinarySerializeTypeMetadata.cs +++ b/AyCode.Core/Serializers/Binaries/AcBinarySerializer.BinarySerializeTypeMetadata.cs @@ -55,6 +55,34 @@ public static partial class AcBinarySerializer /// private int[]? _metadataPropertyHashes; + /// + /// Lazy-computed array of reference properties (complex types + strings). + /// Used by scan pass to quickly iterate only properties that need reference tracking. + /// + private BinaryPropertyAccessor[]? _referenceProperties; + + /// + /// Gets the array of reference properties (complex types + strings). + /// Computed lazily on first access. + /// + public BinaryPropertyAccessor[] ReferenceProperties + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => _referenceProperties ??= ComputeReferenceProperties(); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private BinaryPropertyAccessor[] ComputeReferenceProperties() + { + var list = new List(); + foreach (var prop in Properties) + { + if (prop.IsComplexType || prop.AccessorType == PropertyAccessorType.String) + list.Add(prop); + } + return list.ToArray(); + } + public int[] MetadataPropertyHashes { [MethodImpl(MethodImplOptions.AggressiveInlining)]