1- using System . Runtime . CompilerServices ;
2- using System . Runtime . Intrinsics ;
1+ using System . Runtime . Intrinsics ;
32
43namespace DaanV2 . UUID ;
54
@@ -28,15 +27,20 @@ public static Vector128<Byte> Create(Version version, Variant variant, Vector128
2827 return StampVersion ( mask , overlay , data ) ;
2928 }
3029
31- /// <summary>Uses the given mask and overlay to insert the version and variant onto the data</summary>
32- /// <param name="versionMask">The mask of the versions and variants</param>
33- /// <param name="versionOverlay">The overlay of the versions and variants</param>
34- /// <param name="data">The data to stamp the version and variant onto</param>
35- /// <returns>Returns a <see cref="Vector128{T}"/></returns>
36- [ MethodImpl ( MethodImplOptions . AggressiveInlining | MethodImplOptions . AggressiveOptimization ) ]
37- public static Vector128 < Byte > StampVersion ( Vector128 < Byte > versionMask , Vector128 < Byte > versionOverlay , Vector128 < Byte > data ) {
38- var result = Vector128 . BitwiseAnd ( data , versionMask ) ;
39- result = Vector128 . BitwiseOr ( result , versionOverlay ) ;
40- return result ;
30+ /// <summary>Creates a layout of the data along with version and variant, the provided data will be placed around the version and variant</summary>
31+ /// <param name="version">The version to set</param>
32+ /// <param name="variant">The variant to set</param>
33+ /// <param name="dataA">48 bits of data, top 16 will be removed</param>
34+ /// <param name="dataB">12 bits of data, top 4 will be removed</param>
35+ /// <param name="dataC">62 bits of data, top 2 will be removed</param>
36+ /// <returns></returns>
37+ public static Vector128 < Byte > Create ( Version version , Variant variant , UInt64 dataA , UInt16 dataB , UInt64 dataC ) {
38+ // 48 bits of data in the top, 16 bits will be removed
39+ UInt64 upper = dataA << 16 ;
40+ // 12 bits in the lower, 4 bits in the middle for the version.
41+ upper |= dataB ;
42+
43+ // 62 bits of data in the lower, 2 bits in the top for the variant.
44+ return Create ( version , variant , upper , dataC ) ;
4145 }
4246}
0 commit comments