From b971905fe6b61c426d79f27cb6713bbbff4c84dc Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 29 Aug 2019 02:50:22 +0200 Subject: [PATCH] Minor code refactoring --- .../Mappings/HlslKnownTypes.cs | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs index 1d1f7a19..2409c158 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs @@ -44,17 +44,19 @@ namespace ComputeSharp.Shaders.Mappings [typeof(ReadWriteBuffer<>).FullName] = "RWStructuredBuffer" }; - /// - /// Gets the known HLSL vector types available as mapped types - /// - public static IReadOnlyList HlslMappedVectorTypes { get; } = new[] + private static HashSet _HlslMappedVectorTypes { get; } = new HashSet(new[] { typeof(Bool2), typeof(Bool3), typeof(Bool4), typeof(Int2), typeof(Int3), typeof(Int4), typeof(UInt2), typeof(UInt3), typeof(UInt4), typeof(Float2), typeof(Float3), typeof(Float4), typeof(Double2), typeof(Double3), typeof(Double4) - }; + }); + + /// + /// Gets the known HLSL vector types available as mapped types + /// + public static IReadOnlyCollection HlslMappedVectorTypes => _HlslMappedVectorTypes; /// /// Checks whether or not the input type is a known scalar type @@ -74,24 +76,10 @@ namespace ComputeSharp.Shaders.Mappings /// The input instance to check /// A indicating whether the input is in fact a known HLSL vector type [Pure] - public static bool IsKnownVectorType(Type type) => type == typeof(Bool2) || - type == typeof(Bool3) || - type == typeof(Bool4) || - type == typeof(Int2) || - type == typeof(Int3) || - type == typeof(Int4) || - type == typeof(UInt2) || - type == typeof(UInt3) || - type == typeof(UInt4) || - type == typeof(Float2) || - type == typeof(Float3) || - type == typeof(Float4) || + public static bool IsKnownVectorType(Type type) => _HlslMappedVectorTypes.Contains(type) || type == typeof(Vector2) || type == typeof(Vector3) || - type == typeof(Vector4) || - type == typeof(Double2) || - type == typeof(Double3) || - type == typeof(Double4); + type == typeof(Vector4); /// /// Checks whether or not the input type is a value