diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs index 2b447f9..0ce5fed 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs @@ -40,15 +40,12 @@ namespace YooAsset.Editor manifest.OutputNameStyle = (int)buildParameters.OutputNameStyle; manifest.PackageName = buildParameters.PackageName; manifest.PackageVersion = buildParameters.PackageVersion; + + // 填充资源包集合 manifest.BundleList = GetAllPackageBundle(context); - int len = manifest.BundleList.Count; - manifest.BundleListMap = new Dictionary(len); - - for (int i = 0; i < len; i++) - { - var item = manifest.BundleList[i]; - manifest.BundleListMap.Add(item.BundleName,i); - } + CacheBundleIDs(manifest); + + // 填充主资源集合 manifest.AssetList = GetAllPackageAsset(context, manifest); // 更新Unity内置资源包的引用关系 @@ -95,7 +92,7 @@ namespace YooAsset.Editor string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion); string filePath = $"{packageOutputDirectory}/{fileName}"; ManifestTools.SerializeToBinary(filePath, manifest); - packageHash = HashUtility.FileXXhash(filePath); + packageHash = HashUtility.FileMD5(filePath); BuildLogger.Log($"创建补丁清单文件:{filePath}"); ManifestContext manifestContext = new ManifestContext(); @@ -155,7 +152,7 @@ namespace YooAsset.Editor packageAsset.AssetPath = assetInfo.AssetPath; packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty; packageAsset.AssetTags = assetInfo.AssetTags.ToArray(); - packageAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, manifest); + packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName); packageAsset.DependIDs = GetAssetBundleDependIDs(packageAsset.BundleID, assetInfo, manifest); result.Add(packageAsset); } @@ -169,7 +166,7 @@ namespace YooAsset.Editor { if (dependAssetInfo.HasBundleName()) { - int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, manifest); + int bundleID = GetCachedBundleID(dependAssetInfo.BundleName); if (mainBundleID != bundleID) { if (result.Contains(bundleID) == false) @@ -179,21 +176,6 @@ namespace YooAsset.Editor } return result.ToArray(); } - private int GetAssetBundleID(string bundleName, PackageManifest manifest) - { - // for (int index = 0; index < manifest.BundleList.Count; index++) - // { - // if (manifest.BundleList[index].BundleName == bundleName) - // return index; - // } - - if (manifest.BundleListMap.ContainsKey(bundleName)) - { - return manifest.BundleListMap[bundleName]; - } - - throw new Exception($"Not found bundle name : {bundleName}"); - } /// /// 更新Unity内置资源包的引用关系 @@ -264,8 +246,18 @@ namespace YooAsset.Editor #region 资源包引用关系相关 private readonly Dictionary _cachedBundleID = new Dictionary(10000); private readonly Dictionary _cachedBundleDepends = new Dictionary(10000); + + private void CacheBundleIDs(PackageManifest manifest) + { + UnityEngine.Debug.Assert(manifest.BundleList.Count == 0); + for (int index = 0; index < manifest.BundleList.Count; index++) + { + string bundleName = manifest.BundleList[index].BundleName; + _cachedBundleID.Add(bundleName, index); + } + } - private void UpdateScriptPipelineReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext) + private void UpdateScriptPipelineReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext) { int progressValue; int totalCount = manifest.BundleList.Count; @@ -275,7 +267,7 @@ namespace YooAsset.Editor progressValue = 0; foreach (var packageBundle in manifest.BundleList) { - int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest); + int bundleID = GetCachedBundleID(packageBundle.BundleName); _cachedBundleID.Add(packageBundle.BundleName, bundleID); int pro = ++progressValue; if (pro % 100 == 0) @@ -331,7 +323,7 @@ namespace YooAsset.Editor progressValue = 0; foreach (var packageBundle in manifest.BundleList) { - int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest); + int bundleID = GetCachedBundleID(packageBundle.BundleName); _cachedBundleID.Add(packageBundle.BundleName, bundleID); int pro = ++progressValue; if (pro % 100 == 0) @@ -368,7 +360,7 @@ namespace YooAsset.Editor { packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle); int pro = ++progressValue; - if (pro%100==0) + if (pro % 100 == 0) { EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount); } @@ -382,7 +374,7 @@ namespace YooAsset.Editor foreach (var packageBundle in manifest.BundleList) { string bundleName = packageBundle.BundleName; - if (packageBundle.Equals(targetBundle) || packageBundle.IsRawFile) + if (bundleName == targetBundle.BundleName) continue; string[] dependencies = GetCachedBundleDepends(bundleName); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs index 19c9125..ab7e63f 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs @@ -68,7 +68,7 @@ namespace YooAsset.Editor if (bundleInfo.IsRawFile) { string filePath = bundleInfo.PackageSourceFilePath; - return HashUtility.FileXXhash(filePath); + return HashUtility.FileMD5(filePath); } if (parameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline) @@ -132,7 +132,7 @@ namespace YooAsset.Editor if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild) return "00000000000000000000000000000000"; //32位 else - return HashUtility.FileXXhash(filePath); + return HashUtility.FileMD5(filePath); } private string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext) { diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs index c45da5e..8e0c698 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs @@ -208,6 +208,10 @@ namespace YooAsset packageBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle); Manifest.BundleDic.Add(packageBundle.BundleName, packageBundle); + // 注意:原始文件可能存在相同的CacheGUID + if (Manifest.CacheGUIDs.Contains(packageBundle.CacheGUID) == false) + Manifest.CacheGUIDs.Add(packageBundle.CacheGUID); + _packageBundleCount--; Progress = 1f - _packageBundleCount / _progressTotalValue; if (OperationSystem.IsBusy) diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs index fd6d887..0ea054c 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/LoadCacheManifestOperation.cs @@ -77,7 +77,7 @@ namespace YooAsset return; } - string fileHash = HashUtility.FileXXhash(_manifestFilePath); + string fileHash = HashUtility.FileMD5(_manifestFilePath); if (fileHash != _queryCachePackageHashOp.PackageHash) { _steps = ESteps.Done; diff --git a/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs b/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs index 2c53d36..4db8926 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs @@ -57,8 +57,6 @@ namespace YooAsset /// public List BundleList = new List(); - public Dictionary BundleListMap; - /// /// 资源包集合(提供BundleName获取PackageBundle) @@ -84,6 +82,12 @@ namespace YooAsset [NonSerialized] public Dictionary AssetPathMapping2; + /// + /// 该资源清单所有文件的缓存GUID集合 + /// + [NonSerialized] + public HashSet CacheGUIDs = new HashSet(); + /// /// 尝试映射为资源路径 @@ -193,12 +197,7 @@ namespace YooAsset /// public bool IsIncludeBundleFile(string cacheGUID) { - foreach (var packageBundle in BundleList) - { - if (packageBundle.CacheGUID == cacheGUID) - return true; - } - return false; + return CacheGUIDs.Contains(cacheGUID); } /// diff --git a/Assets/YooAsset/Runtime/Plugins.meta b/Assets/YooAsset/Runtime/Plugins.meta deleted file mode 100644 index 98f9a5c..0000000 --- a/Assets/YooAsset/Runtime/Plugins.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 626314312007949aebb542dcbbfe1a78 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/Plugins/System.Runtime.CompilerServices.Unsafe.dll b/Assets/YooAsset/Runtime/Plugins/System.Runtime.CompilerServices.Unsafe.dll deleted file mode 100644 index 1908d92..0000000 Binary files a/Assets/YooAsset/Runtime/Plugins/System.Runtime.CompilerServices.Unsafe.dll and /dev/null differ diff --git a/Assets/YooAsset/Runtime/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta b/Assets/YooAsset/Runtime/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta deleted file mode 100644 index f75af73..0000000 --- a/Assets/YooAsset/Runtime/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: f9ed697de8b5f18478c683c64e889512 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/Utility/YooUtility.cs b/Assets/YooAsset/Runtime/Utility/YooUtility.cs index 8d854b8..f1dba37 100644 --- a/Assets/YooAsset/Runtime/Utility/YooUtility.cs +++ b/Assets/YooAsset/Runtime/Utility/YooUtility.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Text; using System.IO; using System.Security.Cryptography; -using Standart.Hash.xxHash; namespace YooAsset { @@ -281,28 +280,6 @@ namespace YooAsset return string.Empty; } } - - - /// - /// 获取文件的XXXhash32 - /// - /// - /// - public static string FileXXhash(string filePath) - { - try - { - using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - return xxHash32.ComputeHash(fs).ToString("x8"); - } - } - catch (Exception e) - { - YooLogger.Exception(e); - return string.Empty; - } - } /// /// 获取数据流的MD5 diff --git a/Assets/YooAsset/Runtime/YooAsset.asmdef b/Assets/YooAsset/Runtime/YooAsset.asmdef index f3b53a8..e61c9d1 100644 --- a/Assets/YooAsset/Runtime/YooAsset.asmdef +++ b/Assets/YooAsset/Runtime/YooAsset.asmdef @@ -4,7 +4,7 @@ "references": [], "includePlatforms": [], "excludePlatforms": [], - "allowUnsafeCode": true, + "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, diff --git a/Assets/YooAsset/Runtime/xxHash.meta b/Assets/YooAsset/Runtime/xxHash.meta deleted file mode 100644 index dc9860f..0000000 --- a/Assets/YooAsset/Runtime/xxHash.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 99e361f80e17cb540a43e670a09a4745 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/Utils.cs b/Assets/YooAsset/Runtime/xxHash/Utils.cs deleted file mode 100644 index 7168007..0000000 --- a/Assets/YooAsset/Runtime/xxHash/Utils.cs +++ /dev/null @@ -1,260 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static class Utils - { - public static Guid ToGuid(this uint128 value) - { - var a = (Int32) (value.low64); - var b = (Int16) (value.low64 >> 32); - var c = (Int16) (value.low64 >> 48); - - var d = (Byte) (value.high64); - var e = (Byte) (value.high64 >> 8); - var f = (Byte) (value.high64 >> 16); - var g = (Byte) (value.high64 >> 24); - var h = (Byte) (value.high64 >> 32); - var i = (Byte) (value.high64 >> 40); - var j = (Byte) (value.high64 >> 48); - var k = (Byte) (value.high64 >> 56); - - return new Guid(a, b, c, d, e, f,g, h, i, j, k); - } - - public static byte[] ToBytes(this uint128 value) - { - // allocation - byte[] bytes = new byte[sizeof(ulong) * 2]; - Unsafe.As(ref bytes[0]) = value.low64; - Unsafe.As(ref bytes[8]) = value.high64; - return bytes; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static unsafe void BlockCopy(byte[] src, int srcOffset, byte[] dst, int dstOffset, int count) - { - Debug.Assert(src != null); - Debug.Assert(dst != null); - Debug.Assert(srcOffset >= 0 && srcOffset < src.Length); - Debug.Assert(dstOffset >= 0 && dstOffset < dst.Length); - Debug.Assert(count >= 0); - Debug.Assert(count + srcOffset <= src.Length); - Debug.Assert(count + dstOffset <= dst.Length); - - fixed (byte* pSrc = &src[srcOffset]) - fixed (byte* pDst = &dst[dstOffset]) - { - byte* ptrSrc = pSrc; - byte* ptrDst = pDst; - - SMALLTABLE: - switch (count) - { - case 0: - return; - case 1: - *ptrDst = *ptrSrc; - return; - case 2: - *(short*)ptrDst = *(short*)ptrSrc; - return; - case 3: - *(short*)(ptrDst + 0) = *(short*)(ptrSrc + 0); - *(ptrDst + 2) = *(ptrSrc + 2); - return; - case 4: - *(int*)ptrDst = *(int*)ptrSrc; - return; - case 5: - *(int*)(ptrDst + 0) = *(int*)(ptrSrc + 0); - *(ptrDst + 4) = *(ptrSrc + 4); - return; - case 6: - *(int*)(ptrDst + 0) = *(int*)(ptrSrc + 0); - *(short*)(ptrDst + 4) = *(short*)(ptrSrc + 4); - return; - case 7: - *(int*)(ptrDst + 0) = *(int*)(ptrSrc + 0); - *(short*)(ptrDst + 4) = *(short*)(ptrSrc + 4); - *(ptrDst + 6) = *(ptrSrc + 6); - return; - case 8: - *(long*)ptrDst = *(long*)ptrSrc; - return; - case 9: - *(long*)(ptrDst + 0) = *(long*)(ptrSrc + 0); - *(ptrDst + 8) = *(ptrSrc + 8); - return; - case 10: - *(long*)(ptrDst + 0) = *(long*)(ptrSrc + 0); - *(short*)(ptrDst + 8) = *(short*)(ptrSrc + 8); - return; - case 11: - *(long*)(ptrDst + 0) = *(long*)(ptrSrc + 0); - *(short*)(ptrDst + 8) = *(short*)(ptrSrc + 8); - *(ptrDst + 10) = *(ptrSrc + 10); - return; - case 12: - *(long*)ptrDst = *(long*)ptrSrc; - *(int*)(ptrDst + 8) = *(int*)(ptrSrc + 8); - return; - case 13: - *(long*)(ptrDst + 0) = *(long*)(ptrSrc + 0); - *(int*)(ptrDst + 8) = *(int*)(ptrSrc + 8); - *(ptrDst + 12) = *(ptrSrc + 12); - return; - case 14: - *(long*)(ptrDst + 0) = *(long*)(ptrSrc + 0); - *(int*)(ptrDst + 8) = *(int*)(ptrSrc + 8); - *(short*)(ptrDst + 12) = *(short*)(ptrSrc + 12); - return; - case 15: - *(long*)(ptrDst + 0) = *(long*)(ptrSrc + 0); - *(int*)(ptrDst + 8) = *(int*)(ptrSrc + 8); - *(short*)(ptrDst + 12) = *(short*)(ptrSrc + 12); - *(ptrDst + 14) = *(ptrSrc + 14); - return; - case 16: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - return; - case 17: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(ptrDst + 16) = *(ptrSrc + 16); - return; - case 18: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(short*)(ptrDst + 16) = *(short*)(ptrSrc + 16); - return; - case 19: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(short*)(ptrDst + 16) = *(short*)(ptrSrc + 16); - *(ptrDst + 18) = *(ptrSrc + 18); - return; - case 20: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(int*)(ptrDst + 16) = *(int*)(ptrSrc + 16); - return; - - case 21: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(int*)(ptrDst + 16) = *(int*)(ptrSrc + 16); - *(ptrDst + 20) = *(ptrSrc + 20); - return; - case 22: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(int*)(ptrDst + 16) = *(int*)(ptrSrc + 16); - *(short*)(ptrDst + 20) = *(short*)(ptrSrc + 20); - return; - case 23: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(int*)(ptrDst + 16) = *(int*)(ptrSrc + 16); - *(short*)(ptrDst + 20) = *(short*)(ptrSrc + 20); - *(ptrDst + 22) = *(ptrSrc + 22); - return; - case 24: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - return; - case 25: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(ptrDst + 24) = *(ptrSrc + 24); - return; - case 26: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(short*)(ptrDst + 24) = *(short*)(ptrSrc + 24); - return; - case 27: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(short*)(ptrDst + 24) = *(short*)(ptrSrc + 24); - *(ptrDst + 26) = *(ptrSrc + 26); - return; - case 28: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(int*)(ptrDst + 24) = *(int*)(ptrSrc + 24); - return; - case 29: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(int*)(ptrDst + 24) = *(int*)(ptrSrc + 24); - *(ptrDst + 28) = *(ptrSrc + 28); - return; - case 30: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(int*)(ptrDst + 24) = *(int*)(ptrSrc + 24); - *(short*)(ptrDst + 28) = *(short*)(ptrSrc + 28); - return; - case 31: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(int*)(ptrDst + 24) = *(int*)(ptrSrc + 24); - *(short*)(ptrDst + 28) = *(short*)(ptrSrc + 28); - *(ptrDst + 30) = *(ptrSrc + 30); - return; - case 32: - *(long*)ptrDst = *(long*)ptrSrc; - *(long*)(ptrDst + 8) = *(long*)(ptrSrc + 8); - *(long*)(ptrDst + 16) = *(long*)(ptrSrc + 16); - *(long*)(ptrDst + 24) = *(long*)(ptrSrc + 24); - return; - } - - long* lpSrc = (long*)ptrSrc; - long* ldSrc = (long*)ptrDst; - while (count >= 64) - { - *(ldSrc + 0) = *(lpSrc + 0); - *(ldSrc + 1) = *(lpSrc + 1); - *(ldSrc + 2) = *(lpSrc + 2); - *(ldSrc + 3) = *(lpSrc + 3); - *(ldSrc + 4) = *(lpSrc + 4); - *(ldSrc + 5) = *(lpSrc + 5); - *(ldSrc + 6) = *(lpSrc + 6); - *(ldSrc + 7) = *(lpSrc + 7); - if (count == 64) - return; - count -= 64; - lpSrc += 8; - ldSrc += 8; - } - if (count > 32) - { - *(ldSrc + 0) = *(lpSrc + 0); - *(ldSrc + 1) = *(lpSrc + 1); - *(ldSrc + 2) = *(lpSrc + 2); - *(ldSrc + 3) = *(lpSrc + 3); - count -= 32; - lpSrc += 4; - ldSrc += 4; - } - - ptrSrc = (byte*)lpSrc; - ptrDst = (byte*)ldSrc; - goto SMALLTABLE; - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/Utils.cs.meta b/Assets/YooAsset/Runtime/xxHash/Utils.cs.meta deleted file mode 100644 index 3901b6f..0000000 --- a/Assets/YooAsset/Runtime/xxHash/Utils.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 07b97cff0161f014f857bb23a25d73a9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash32.cs b/Assets/YooAsset/Runtime/xxHash/__inline__xxHash32.cs deleted file mode 100644 index 078f8c0..0000000 --- a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash32.cs +++ /dev/null @@ -1,191 +0,0 @@ -/* -* This is the auto generated code. -* All function calls are inlined in XXH32 -* Please don't try to analyze it. -*/ - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public partial class xxHash32 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint __inline__XXH32(byte* input, int len, uint seed) - { - uint h32; - - if (len >= 16) - { - byte* end = input + len; - byte* limit = end - 15; - - uint v1 = seed + XXH_PRIME32_1 + XXH_PRIME32_2; - uint v2 = seed + XXH_PRIME32_2; - uint v3 = seed + 0; - uint v4 = seed - XXH_PRIME32_1; - - do - { - var reg1 = *((uint*)(input + 0)); - var reg2 = *((uint*)(input + 4)); - var reg3 = *((uint*)(input + 8)); - var reg4 = *((uint*)(input + 12)); - - // XXH32_round - v1 += reg1 * XXH_PRIME32_2; - v1 = (v1 << 13) | (v1 >> (32 - 13)); - v1 *= XXH_PRIME32_1; - - // XXH32_round - v2 += reg2 * XXH_PRIME32_2; - v2 = (v2 << 13) | (v2 >> (32 - 13)); - v2 *= XXH_PRIME32_1; - - // XXH32_round - v3 += reg3 * XXH_PRIME32_2; - v3 = (v3 << 13) | (v3 >> (32 - 13)); - v3 *= XXH_PRIME32_1; - - // XXH32_round - v4 += reg4 * XXH_PRIME32_2; - v4 = (v4 << 13) | (v4 >> (32 - 13)); - v4 *= XXH_PRIME32_1; - - input += 16; - } while (input < limit); - - h32 = ((v1 << 1) | (v1 >> (32 - 1))) + - ((v2 << 7) | (v2 >> (32 - 7))) + - ((v3 << 12) | (v3 >> (32 - 12))) + - ((v4 << 18) | (v4 >> (32 - 18))); - } - else - { - h32 = seed + XXH_PRIME32_5; - } - - h32 += (uint) len; - - // XXH32_finalize - len &= 15; - while (len >= 4) - { - h32 += *((uint*) input) * XXH_PRIME32_3; - input += 4; - h32 = ((h32 << 17) | (h32 >> (32 - 17))) * XXH_PRIME32_4; - len -= 4; - } - - while (len > 0) - { - h32 += *((byte*) input) * XXH_PRIME32_5; - ++input; - h32 = ((h32 << 11) | (h32 >> (32 - 11))) * XXH_PRIME32_1; - --len; - } - - // XXH32_avalanche - h32 ^= h32 >> 15; - h32 *= XXH_PRIME32_2; - h32 ^= h32 >> 13; - h32 *= XXH_PRIME32_3; - h32 ^= h32 >> 16; - - return h32; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void __inline__XXH32_stream_process(byte[] input, int len, ref uint v1, ref uint v2, ref uint v3, ref uint v4) - { - fixed (byte* pData = &input[0]) - { - byte* ptr = pData; - byte* limit = ptr + len; - - do - { - var reg1 = *((uint*)(ptr + 0)); - var reg2 = *((uint*)(ptr + 4)); - var reg3 = *((uint*)(ptr + 8)); - var reg4 = *((uint*)(ptr + 12)); - - // XXH32_round - v1 += reg1 * XXH_PRIME32_2; - v1 = (v1 << 13) | (v1 >> (32 - 13)); - v1 *= XXH_PRIME32_1; - - // XXH32_round - v2 += reg2 * XXH_PRIME32_2; - v2 = (v2 << 13) | (v2 >> (32 - 13)); - v2 *= XXH_PRIME32_1; - - // XXH32_round - v3 += reg3 * XXH_PRIME32_2; - v3 = (v3 << 13) | (v3 >> (32 - 13)); - v3 *= XXH_PRIME32_1; - - // XXH32_round - v4 += reg4 * XXH_PRIME32_2; - v4 = (v4 << 13) | (v4 >> (32 - 13)); - v4 *= XXH_PRIME32_1; - - ptr += 16; - - } while (ptr < limit); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint __inline__XXH32_stream_finalize(byte[] input, int len, ref uint v1, ref uint v2, ref uint v3, ref uint v4, long length, uint seed) - { - fixed (byte* pData = &input[0]) - { - byte* ptr = pData; - uint h32; - - if (length >= 16) - { - h32 = ((v1 << 1) | (v1 >> (32 - 1))) + - ((v2 << 7) | (v2 >> (32 - 7))) + - ((v3 << 12) | (v3 >> (32 - 12))) + - ((v4 << 18) | (v4 >> (32 - 18))); - } - else - { - h32 = seed + XXH_PRIME32_5; - } - - h32 += (uint)length; - - // XXH32_finalize - len &= 15; - while (len >= 4) - { - h32 += *((uint*)ptr) * XXH_PRIME32_3; - ptr += 4; - h32 = ((h32 << 17) | (h32 >> (32 - 17))) * XXH_PRIME32_4; - len -= 4; - } - - while (len > 0) - { - h32 += *((byte*)ptr) * XXH_PRIME32_5; - ptr++; - h32 = ((h32 << 11) | (h32 >> (32 - 11))) * XXH_PRIME32_1; - len--; - } - - // XXH32_avalanche - h32 ^= h32 >> 15; - h32 *= XXH_PRIME32_2; - h32 ^= h32 >> 13; - h32 *= XXH_PRIME32_3; - h32 ^= h32 >> 16; - - return h32; - } - } - } -} - diff --git a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash32.cs.meta b/Assets/YooAsset/Runtime/xxHash/__inline__xxHash32.cs.meta deleted file mode 100644 index d552a7f..0000000 --- a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7bd3966e4951b294d8cda4a41bb4b690 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash64.cs b/Assets/YooAsset/Runtime/xxHash/__inline__xxHash64.cs deleted file mode 100644 index 451dbf4..0000000 --- a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash64.cs +++ /dev/null @@ -1,252 +0,0 @@ -/* -* This is the auto generated code. -* All function calls are inlined in XXH64 -* Please don't try to analyze it. -*/ - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public partial class xxHash64 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong __inline__XXH64(byte* input, int len, ulong seed) - { - ulong h64; - - if (len >= 32) - { - byte* end = input + len; - byte* limit = end - 31; - - ulong v1 = seed + XXH_PRIME64_1 + XXH_PRIME64_2; - ulong v2 = seed + XXH_PRIME64_2; - ulong v3 = seed + 0; - ulong v4 = seed - XXH_PRIME64_1; - - do - { - var reg1 = *((ulong*)(input + 0)); - var reg2 = *((ulong*)(input + 8)); - var reg3 = *((ulong*)(input + 16)); - var reg4 = *((ulong*)(input + 24)); - - // XXH64_round - v1 += reg1 * XXH_PRIME64_2; - v1 = (v1 << 31) | (v1 >> (64 - 31)); - v1 *= XXH_PRIME64_1; - - // XXH64_round - v2 += reg2 * XXH_PRIME64_2; - v2 = (v2 << 31) | (v2 >> (64 - 31)); - v2 *= XXH_PRIME64_1; - - // XXH64_round - v3 += reg3 * XXH_PRIME64_2; - v3 = (v3 << 31) | (v3 >> (64 - 31)); - v3 *= XXH_PRIME64_1; - - // XXH64_round - v4 += reg4 * XXH_PRIME64_2; - v4 = (v4 << 31) | (v4 >> (64 - 31)); - v4 *= XXH_PRIME64_1; - input += 32; - } while (input < limit); - - h64 = ((v1 << 1) | (v1 >> (64 - 1))) + - ((v2 << 7) | (v2 >> (64 - 7))) + - ((v3 << 12) | (v3 >> (64 - 12))) + - ((v4 << 18) | (v4 >> (64 - 18))); - - // XXH64_mergeRound - v1 *= XXH_PRIME64_2; - v1 = (v1 << 31) | (v1 >> (64 - 31)); - v1 *= XXH_PRIME64_1; - h64 ^= v1; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - - // XXH64_mergeRound - v2 *= XXH_PRIME64_2; - v2 = (v2 << 31) | (v2 >> (64 - 31)); - v2 *= XXH_PRIME64_1; - h64 ^= v2; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - - // XXH64_mergeRound - v3 *= XXH_PRIME64_2; - v3 = (v3 << 31) | (v3 >> (64 - 31)); - v3 *= XXH_PRIME64_1; - h64 ^= v3; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - - // XXH64_mergeRound - v4 *= XXH_PRIME64_2; - v4 = (v4 << 31) | (v4 >> (64 - 31)); - v4 *= XXH_PRIME64_1; - h64 ^= v4; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - } - else - { - h64 = seed + XXH_PRIME64_5; - } - - h64 += (ulong) len; - - // XXH64_finalize - len &= 31; - while (len >= 8) { - ulong k1 = XXH64_round(0, *(ulong*)input); - input += 8; - h64 ^= k1; - h64 = XXH_rotl64(h64,27) * XXH_PRIME64_1 + XXH_PRIME64_4; - len -= 8; - } - if (len >= 4) { - h64 ^= *(uint*)input * XXH_PRIME64_1; - input += 4; - h64 = XXH_rotl64(h64, 23) * XXH_PRIME64_2 + XXH_PRIME64_3; - len -= 4; - } - while (len > 0) { - h64 ^= (*input++) * XXH_PRIME64_5; - h64 = XXH_rotl64(h64, 11) * XXH_PRIME64_1; - --len; - } - - // XXH64_avalanche - h64 ^= h64 >> 33; - h64 *= XXH_PRIME64_2; - h64 ^= h64 >> 29; - h64 *= XXH_PRIME64_3; - h64 ^= h64 >> 32; - - return h64; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void __inline__XXH64_stream_process(byte[] input, int len, ref ulong v1, ref ulong v2, ref ulong v3, - ref ulong v4) - { - fixed (byte* pData = &input[0]) - { - byte* ptr = pData; - byte* limit = ptr + len; - - do - { - var reg1 = *((ulong*)(ptr + 0)); - var reg2 = *((ulong*)(ptr + 8)); - var reg3 = *((ulong*)(ptr + 16)); - var reg4 = *((ulong*)(ptr + 24)); - - // XXH64_round - v1 += reg1 * XXH_PRIME64_2; - v1 = (v1 << 31) | (v1 >> (64 - 31)); - v1 *= XXH_PRIME64_1; - - // XXH64_round - v2 += reg2 * XXH_PRIME64_2; - v2 = (v2 << 31) | (v2 >> (64 - 31)); - v2 *= XXH_PRIME64_1; - - // XXH64_round - v3 += reg3 * XXH_PRIME64_2; - v3 = (v3 << 31) | (v3 >> (64 - 31)); - v3 *= XXH_PRIME64_1; - - // XXH64_round - v4 += reg4 * XXH_PRIME64_2; - v4 = (v4 << 31) | (v4 >> (64 - 31)); - v4 *= XXH_PRIME64_1; - ptr += 32; - } while (ptr < limit); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong __inline__XXH64_stream_finalize(byte[] input, int len, ref ulong v1, ref ulong v2, ref ulong v3, - ref ulong v4, long length, ulong seed) - { - fixed (byte* pData = &input[0]) - { - byte* ptr = pData; - byte* end = pData + len; - ulong h64; - - if (length >= 32) - { - h64 = ((v1 << 1) | (v1 >> (64 - 1))) + - ((v2 << 7) | (v2 >> (64 - 7))) + - ((v3 << 12) | (v3 >> (64 - 12))) + - ((v4 << 18) | (v4 >> (64 - 18))); - - // XXH64_mergeRound - v1 *= XXH_PRIME64_2; - v1 = (v1 << 31) | (v1 >> (64 - 31)); - v1 *= XXH_PRIME64_1; - h64 ^= v1; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - - // XXH64_mergeRound - v2 *= XXH_PRIME64_2; - v2 = (v2 << 31) | (v2 >> (64 - 31)); - v2 *= XXH_PRIME64_1; - h64 ^= v2; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - - // XXH64_mergeRound - v3 *= XXH_PRIME64_2; - v3 = (v3 << 31) | (v3 >> (64 - 31)); - v3 *= XXH_PRIME64_1; - h64 ^= v3; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - - // XXH64_mergeRound - v4 *= XXH_PRIME64_2; - v4 = (v4 << 31) | (v4 >> (64 - 31)); - v4 *= XXH_PRIME64_1; - h64 ^= v4; - h64 = h64 * XXH_PRIME64_1 + XXH_PRIME64_4; - } - else - { - h64 = seed + XXH_PRIME64_5; - } - - h64 += (ulong) length; - - // XXH64_finalize - len &= 31; - while (len >= 8) { - ulong k1 = XXH64_round(0, *(ulong*)ptr); - ptr += 8; - h64 ^= k1; - h64 = XXH_rotl64(h64,27) * XXH_PRIME64_1 + XXH_PRIME64_4; - len -= 8; - } - if (len >= 4) { - h64 ^= *(uint*)ptr * XXH_PRIME64_1; - ptr += 4; - h64 = XXH_rotl64(h64, 23) * XXH_PRIME64_2 + XXH_PRIME64_3; - len -= 4; - } - while (len > 0) { - h64 ^= (*ptr++) * XXH_PRIME64_5; - h64 = XXH_rotl64(h64, 11) * XXH_PRIME64_1; - --len; - } - - // XXH64_avalanche - h64 ^= h64 >> 33; - h64 *= XXH_PRIME64_2; - h64 ^= h64 >> 29; - h64 *= XXH_PRIME64_3; - h64 ^= h64 >> 32; - - return h64; - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash64.cs.meta b/Assets/YooAsset/Runtime/xxHash/__inline__xxHash64.cs.meta deleted file mode 100644 index 717881a..0000000 --- a/Assets/YooAsset/Runtime/xxHash/__inline__xxHash64.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 81174f2235c739845b98c1eed4778f17 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH.cs b/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH.cs deleted file mode 100644 index 97809c5..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH.cs +++ /dev/null @@ -1,125 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Runtime.CompilerServices; -namespace Standart.Hash.xxHash -{ - public static partial class xxHash128 - { - private static readonly ulong XXH_PRIME64_1 = 11400714785074694791UL; - private static readonly ulong XXH_PRIME64_2 = 14029467366897019727UL; - private static readonly ulong XXH_PRIME64_3 = 1609587929392839161UL; - private static readonly ulong XXH_PRIME64_4 = 9650029242287828579UL; - private static readonly ulong XXH_PRIME64_5 = 2870177450012600261UL; - - private static readonly uint XXH_PRIME32_1 = 2654435761U; - private static readonly uint XXH_PRIME32_2 = 2246822519U; - private static readonly uint XXH_PRIME32_3 = 3266489917U; - private static readonly uint XXH_PRIME32_4 = 668265263U; - private static readonly uint XXH_PRIME32_5 = 374761393U; - - private static readonly int XXH_STRIPE_LEN = 64; - private static readonly int XXH_ACC_NB = 8; - private static readonly int XXH_SECRET_CONSUME_RATE = 8; - private static readonly int XXH_SECRET_MERGEACCS_START = 11; - private static readonly int XXH_SECRET_DEFAULT_SIZE = 192; - private static readonly int XXH_SECRET_LASTACC_START = 7; - - private static readonly byte MM_SHUFFLE_0_3_0_1 = 0b0011_0001; - private static readonly byte MM_SHUFFLE_1_0_3_2 = 0b0100_1110; - - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint XXH_rotl32(uint x, int r) - { - return (x << r) | (x >> (32 - r)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_rotl64(ulong x, int r) - { - return (x << r) | (x >> (64 - r)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH_readLE64(byte* ptr) - { - return *(ulong*) ptr; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint XXH_readLE32(byte* ptr) - { - return *(uint*) ptr; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_xorshift64(ulong v64, int shift) - { - return v64 ^ (v64 >> shift); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint XXH_swap32(uint x) - { - return ((x << 24) & 0xff000000 ) | - ((x << 8) & 0x00ff0000 ) | - ((x >> 8) & 0x0000ff00 ) | - ((x >> 24) & 0x000000ff ); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_swap64(ulong x) - { - return ((x << 56) & 0xff00000000000000UL) | - ((x << 40) & 0x00ff000000000000UL) | - ((x << 24) & 0x0000ff0000000000UL) | - ((x << 8) & 0x000000ff00000000UL) | - ((x >> 8) & 0x00000000ff000000UL) | - ((x >> 24) & 0x0000000000ff0000UL) | - ((x >> 40) & 0x000000000000ff00UL) | - ((x >> 56) & 0x00000000000000ffUL); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_mult32to64(ulong x, ulong y) - { - return (ulong)(uint)(x) * (ulong)(uint)(y); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint128 XXH_mult64to128(ulong lhs, ulong rhs) - { - - - return XXH_mult64to128_scalar(lhs, rhs); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint128 XXH_mult64to128_scalar(ulong lhs, ulong rhs) - { - ulong lo_lo = XXH_mult32to64(lhs & 0xFFFFFFFF, rhs & 0xFFFFFFFF); - ulong hi_lo = XXH_mult32to64(lhs >> 32, rhs & 0xFFFFFFFF); - ulong lo_hi = XXH_mult32to64(lhs & 0xFFFFFFFF, rhs >> 32); - ulong hi_hi = XXH_mult32to64(lhs >> 32, rhs >> 32); - - ulong cross = (lo_lo >> 32) + (hi_lo & 0xFFFFFFFF) + lo_hi; - ulong upper = (hi_lo >> 32) + (cross >> 32) + hi_hi; - ulong lower = (cross << 32) | (lo_lo & 0xFFFFFFFF); - - uint128 r128; - r128.low64 = lower; - r128.high64 = upper; - return r128; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH_writeLE64(byte* dst, ulong v64) - { - *(ulong*) dst = v64; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH.cs.meta deleted file mode 100644 index 0912cb3..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 45095bcca3212f441b4c38711f0ff93d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH3.cs b/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH3.cs deleted file mode 100644 index 60d4250..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH3.cs +++ /dev/null @@ -1,452 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash128 - { - private static readonly byte[] XXH3_SECRET = - { - 0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c, - 0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f, - 0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21, - 0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c, - 0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3, - 0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8, - 0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d, - 0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64, - 0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb, - 0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e, - 0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce, - 0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e, - }; - - private static readonly ulong[] XXH3_INIT_ACC = - { - XXH_PRIME32_3, XXH_PRIME64_1, XXH_PRIME64_2, XXH_PRIME64_3, - XXH_PRIME64_4, XXH_PRIME32_2, XXH_PRIME64_5, XXH_PRIME32_1 - }; - - private static readonly int XXH3_SECRET_SIZE_MIN = 136; - private static readonly int XXH3_SECRET_DEFAULT_SIZE = 192; - private static readonly int XXH3_MIDSIZE_MAX = 240; - private static readonly int XXH3_MIDSIZE_STARTOFFSET = 3; - private static readonly int XXH3_MIDSIZE_LASTOFFSET = 17; - private static readonly int XXH3_ACC_SIZE = 64; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_128bits_internal(byte* input, int len, ulong seed, byte* secret, int secretLen) - { - Debug.Assert(secretLen >= XXH3_SECRET_SIZE_MIN); - - if (len <= 16) - return XXH3_len_0to16_128b(input, len, secret, seed); - if (len <= 128) - return XXH3_len_17to128_128b(input, len, secret, secretLen, seed); - if (len <= XXH3_MIDSIZE_MAX) - return XXH3_len_129to240_128b(input, len, secret, secretLen, seed); - - return XXH3_hashLong_128b_withSeed(input, len, secret, secretLen, seed); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_len_0to16_128b(byte* input, int len, byte* secret, ulong seed) - { - Debug.Assert(len <= 16); - - if (len > 8) return XXH3_len_9to16_128b(input, len, secret, seed); - if (len >= 4) return XXH3_len_4to8_128b(input, len, secret, seed); - if (len != 0) return XXH3_len_1to3_128b(input, len, secret, seed); - - uint128 h128; - ulong bitflipl = XXH_readLE64(secret + 64) ^ XXH_readLE64(secret + 72); - ulong bitfliph = XXH_readLE64(secret + 80) ^ XXH_readLE64(secret + 88); - h128.low64 = XXH64_avalanche(seed ^ bitflipl); - h128.high64 = XXH64_avalanche(seed ^ bitfliph); - return h128; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_len_17to128_128b(byte* input, int len, byte* secret, int secretSize, ulong seed) - { - Debug.Assert(secretSize >= XXH3_SECRET_SIZE_MIN); - Debug.Assert(16 < len && len <= 128); - - uint128 acc; - acc.low64 = (ulong) len * XXH_PRIME64_1; - acc.high64 = 0; - - if (len > 32) { - if (len > 64) { - if (len > 96) { - acc = XXH128_mix32B(acc, input+48, input+len-64, secret+96, seed); - } - acc = XXH128_mix32B(acc, input+32, input+len-48, secret+64, seed); - } - acc = XXH128_mix32B(acc, input+16, input+len-32, secret+32, seed); - } - acc = XXH128_mix32B(acc, input, input+len-16, secret, seed); - - uint128 h128; - h128.low64 = acc.low64 + acc.high64; - h128.high64 = (acc.low64 * XXH_PRIME64_1) - + (acc.high64 * XXH_PRIME64_4) - + (((ulong) len - seed) * XXH_PRIME64_2); - h128.low64 = XXH3_avalanche(h128.low64); - h128.high64 = (ulong) 0 - XXH3_avalanche(h128.high64); - return h128; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_len_9to16_128b(byte* input, int len, byte* secret, ulong seed) - { - Debug.Assert(input != null); - Debug.Assert(secret != null); - Debug.Assert(9 <= len && len <= 16); - - ulong bitflipl = (XXH_readLE64(secret + 32) ^ XXH_readLE64(secret + 40)) - seed; - ulong bitfliph = (XXH_readLE64(secret + 48) ^ XXH_readLE64(secret + 56)) + seed; - ulong input_lo = XXH_readLE64(input); - ulong input_hi = XXH_readLE64(input + len - 8); - uint128 m128 = XXH_mult64to128(input_lo ^ input_hi ^ bitflipl, XXH_PRIME64_1); - - m128.low64 += (ulong) (len - 1) << 54; - input_hi ^= bitfliph; - - m128.high64 += input_hi + XXH_mult32to64((uint) input_hi, XXH_PRIME32_2 - 1); - m128.low64 ^= XXH_swap64(m128.high64); - - uint128 h128 = XXH_mult64to128(m128.low64, XXH_PRIME64_2); - h128.high64 += m128.high64 * XXH_PRIME64_2; - - h128.low64 = XXH3_avalanche(h128.low64); - h128.high64 = XXH3_avalanche(h128.high64); - return h128; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_len_1to3_128b(byte* input, int len, byte* secret, ulong seed) - { - Debug.Assert(input != null); - Debug.Assert(1 <= len && len <= 3); - Debug.Assert(secret != null); - - byte c1 = input[0]; - byte c2 = input[len >> 1]; - byte c3 = input[len - 1]; - - uint combinedl = ((uint) c1 << 16) | - ((uint) c2 << 24) | - ((uint) c3 << 0) | - ((uint) len << 8); - uint combinedh = XXH_rotl32(XXH_swap32(combinedl), 13); - - ulong bitflipl = (XXH_readLE32(secret) ^ XXH_readLE32(secret + 4)) + seed; - ulong bitfliph = (XXH_readLE32(secret + 8) ^ XXH_readLE32(secret + 12)) - seed; - ulong keyed_lo = (ulong) combinedl ^ bitflipl; - ulong keyed_hi = (ulong) combinedh ^ bitfliph; - - uint128 h128; - h128.low64 = XXH64_avalanche(keyed_lo); - h128.high64 = XXH64_avalanche(keyed_hi); - - return h128; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_len_4to8_128b(byte* input, int len, byte* secret, ulong seed) - { - Debug.Assert(input != null); - Debug.Assert(secret != null); - Debug.Assert(4 <= len && len <= 8); - - seed ^= (ulong) XXH_swap32((uint) seed) << 32; - - uint input_lo = XXH_readLE32(input); - uint input_hi = XXH_readLE32(input + len - 4); - ulong input_64 = input_lo + ((ulong) input_hi << 32); - ulong bitflip = (XXH_readLE64(secret + 16) ^ XXH_readLE64(secret + 24)) + seed; - ulong keyed = input_64 ^ bitflip; - - uint128 m128 = XXH_mult64to128(keyed, XXH_PRIME64_1 + ((ulong) len << 2)); - - m128.high64 += (m128.low64 << 1); - m128.low64 ^= (m128.high64 >> 3); - - m128.low64 = XXH_xorshift64(m128.low64, 35); - m128.low64 *= 0x9FB21C651E98DF25UL; - m128.low64 = XXH_xorshift64(m128.low64, 28); - m128.high64 = XXH3_avalanche(m128.high64); - - return m128; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_len_129to240_128b(byte* input, int len, byte* secret, int secretSize, ulong seed) - { - Debug.Assert(secretSize >= XXH3_SECRET_SIZE_MIN); - Debug.Assert(128 < len && len <= XXH3_MIDSIZE_MAX); - - uint128 acc; - int nbRounds = len / 32; - - acc.low64 = (ulong) len * XXH_PRIME64_1; - acc.high64 = 0; - for (int i = 0; i < 4; i++) { - acc = XXH128_mix32B(acc, - input + (32 * i), - input + (32 * i) + 16, - secret + (32 * i), - seed); - } - - acc.low64 = XXH3_avalanche(acc.low64); - acc.high64 = XXH3_avalanche(acc.high64); - - for (int i = 4 ; i < nbRounds; i++) { - acc = XXH128_mix32B(acc, - input + (32 * i), - input + (32 * i) + 16, - secret + XXH3_MIDSIZE_STARTOFFSET + (32 * (i - 4)), - seed); - } - - acc = XXH128_mix32B(acc, - input + len - 16, - input + len - 32, - secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET - 16, - 0UL - seed); - - uint128 h128; - h128.low64 = acc.low64 + acc.high64; - h128.high64 = (acc.low64 * XXH_PRIME64_1) - + (acc.high64 * XXH_PRIME64_4) - + (((ulong)len - seed) * XXH_PRIME64_2); - h128.low64 = XXH3_avalanche(h128.low64); - h128.high64 = (ulong)0 - XXH3_avalanche(h128.high64); - return h128; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH3_avalanche(ulong h64) - { - h64 = XXH_xorshift64(h64, 37); - h64 *= 0x165667919E3779F9UL; - h64 = XXH_xorshift64(h64, 32); - return h64; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH128_mix32B(uint128 acc, byte* input_1, byte* input_2, byte* secret, ulong seed) - { - acc.low64 += XXH3_mix16B(input_1, secret + 0, seed); - acc.low64 ^= XXH_readLE64(input_2) + XXH_readLE64(input_2 + 8); - acc.high64 += XXH3_mix16B(input_2, secret + 16, seed); - acc.high64 ^= XXH_readLE64(input_1) + XXH_readLE64(input_1 + 8); - return acc; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_mix16B(byte* input, byte* secret, ulong seed) - { - ulong input_lo = XXH_readLE64(input); - ulong input_hi = XXH_readLE64(input + 8); - - return XXH3_mul128_fold64( - input_lo ^ (XXH_readLE64(secret) + seed), - input_hi ^ (XXH_readLE64(secret + 8) - seed) - ); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH3_mul128_fold64(ulong lhs, ulong rhs) - { - uint128 product = XXH_mult64to128(lhs, rhs); - return product.low64 ^ product.high64; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_hashLong_128b_withSeed(byte* input, int len, byte* secret, int secretSize, ulong seed) - { - if (seed == 0) - return XXH3_hashLong_128b_internal(input, len, secret, secretSize); - - byte* customSecret = stackalloc byte[XXH3_SECRET_DEFAULT_SIZE]; - - XXH3_initCustomSecret(customSecret, seed); - - return XXH3_hashLong_128b_internal(input, len, customSecret, XXH3_SECRET_DEFAULT_SIZE); - - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 XXH3_hashLong_128b_internal(byte* input, int len, byte* secret, int secretSize) - { - fixed (ulong* src = &XXH3_INIT_ACC[0]) - { - ulong* acc = stackalloc ulong[8] - { - *(src + 0), - *(src + 1), - *(src + 2), - *(src + 3), - *(src + 4), - *(src + 5), - *(src + 6), - *(src + 7), - }; - - XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize); - - uint128 uint128; - uint128.low64 = XXH3_mergeAccs(acc, - secret + XXH_SECRET_MERGEACCS_START, - (ulong)len * XXH_PRIME64_1); - uint128.high64 = XXH3_mergeAccs(acc, - secret + secretSize - XXH3_ACC_SIZE - XXH_SECRET_MERGEACCS_START, - ~((ulong)len * XXH_PRIME64_2)); - - return uint128; - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_hashLong_internal_loop(ulong* acc, byte* input, int len, byte* secret, int secretSize) - { - Debug.Assert(secretSize >= XXH3_SECRET_SIZE_MIN); - Debug.Assert(len > XXH_STRIPE_LEN); - - int nbStripesPerBlock = (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; - int block_len = XXH_STRIPE_LEN * nbStripesPerBlock; - int nb_blocks = (len - 1) / block_len; - - for (int n = 0; n < nb_blocks; n++) { - XXH3_accumulate(acc, input + n * block_len, secret, nbStripesPerBlock); - XXH3_scrambleAcc(acc, secret + secretSize - XXH_STRIPE_LEN); - } - - int nbStripes = ((len - 1) - (block_len * nb_blocks)) / XXH_STRIPE_LEN; - XXH3_accumulate(acc, input + nb_blocks * block_len, secret, nbStripes); - - byte* p = input + len - XXH_STRIPE_LEN; - XXH3_accumulate_512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_mergeAccs(ulong* acc, byte* secret, ulong start) - { - ulong result64 = start; - - for (int i = 0; i < 4; i++) - result64 += XXH3_mix2Accs(acc + 2 * i, secret + 16 * i); - - return XXH3_avalanche(result64); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_mix2Accs(ulong* acc, byte* secret) - { - return XXH3_mul128_fold64( - acc[0] ^ XXH_readLE64(secret), - acc[1] ^ XXH_readLE64(secret+8) ); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_accumulate(ulong* acc, byte* input, byte* secret, int nbStripes) - { - for (int n = 0; n < nbStripes; n++ ) { - byte* inp = input + n * XXH_STRIPE_LEN; - XXH3_accumulate_512(acc, inp, secret + n * XXH_SECRET_CONSUME_RATE); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_accumulate_512(ulong* acc, byte* input, byte* secret) - { - XXH3_accumulate_512_scalar(acc, input, secret); - - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_accumulate_512_scalar(ulong* acc, byte* input, byte* secret) - { - for (int i = 0; i < XXH_ACC_NB; i++) - XXH3_scalarRound(acc, input, secret, i); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scalarRound(ulong* acc, byte* input, byte* secret, int lane) - { - Debug.Assert(lane < XXH_ACC_NB); - - ulong* xacc = acc; - byte* xinput = input; - byte* xsecret = secret; - - ulong data_val = XXH_readLE64(xinput + lane * 8); - ulong data_key = data_val ^ XXH_readLE64(xsecret + lane * 8); - xacc[lane ^ 1] += data_val; - xacc[lane] += XXH_mult32to64(data_key & 0xFFFFFFFF, data_key >> 32); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scrambleAcc(ulong* acc, byte* secret) - { - XXH3_scrambleAcc_scalar(acc, secret); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scrambleAcc_scalar(ulong* acc, byte* secret) - { - for (int i = 0; i < XXH_ACC_NB; i++) - XXH3_scalarScrambleRound(acc, secret, i); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scalarScrambleRound(ulong* acc, byte* secret, int lane) - { - Debug.Assert(lane < XXH_ACC_NB); - - ulong* xacc = acc; - byte* xsecret = secret; - - ulong key64 = XXH_readLE64(xsecret + lane * 8); - ulong acc64 = xacc[lane]; - acc64 = XXH_xorshift64(acc64, 47); - acc64 ^= key64; - acc64 *= XXH_PRIME32_1; - xacc[lane] = acc64; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_initCustomSecret(byte* customSecret, ulong seed) - { - XXH3_initCustomSecret_scalar(customSecret, seed); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_initCustomSecret_scalar(byte* customSecret, ulong seed) - { - fixed (byte* kSecretPtr = &XXH3_SECRET[0]) - { - int nbRounds = XXH_SECRET_DEFAULT_SIZE / 16; - - for (int i = 0; i < nbRounds; i++) - { - ulong lo = XXH_readLE64(kSecretPtr + 16 * i) + seed; - ulong hi = XXH_readLE64(kSecretPtr + 16 * i + 8) - seed; - XXH_writeLE64((byte*) customSecret + 16 * i, lo); - XXH_writeLE64((byte*) customSecret + 16 * i + 8, hi); - } - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH3.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH3.cs.meta deleted file mode 100644 index f1af4cf..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH3.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1df288f95a653c44dbd9a60f9d9c8979 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH64.cs b/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH64.cs deleted file mode 100644 index 31349bf..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH64.cs +++ /dev/null @@ -1,20 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash128 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH64_avalanche(ulong hash) - { - hash ^= hash >> 33; - hash *= XXH_PRIME64_2; - hash ^= hash >> 29; - hash *= XXH_PRIME64_3; - hash ^= hash >> 32; - return hash; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH64.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH64.cs.meta deleted file mode 100644 index f292e17..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.XXH64.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 47b4bf89c9a50a845808824ae5a4b295 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.cs b/Assets/YooAsset/Runtime/xxHash/xxHash128.cs deleted file mode 100644 index bf6c06d..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.cs +++ /dev/null @@ -1,180 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash128 - { - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe uint128 ComputeHash(byte[] data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe uint128 ComputeHash(Span data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe uint128 ComputeHash(ReadOnlySpan data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed); - } - } - - /// - /// Compute xxHash for the string - /// - /// The source of data - /// The seed number - /// hash - public static unsafe uint128 ComputeHash(string str, ulong seed = 0) - { - Debug.Assert(str != null); - - fixed (char* c = str) - { - byte* ptr = (byte*) c; - int length = str.Length * 2; - - return UnsafeComputeHash(ptr, length, seed); - } - } - - /// - /// Compute hash bytes for the data byte array - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe byte[] ComputeHashBytes(byte[] data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed).ToBytes(); - } - } - - /// - /// Compute hash bytes for the span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe byte[] ComputeHashBytes(Span data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed).ToBytes(); - } - } - - /// - /// Compute hash bytes for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe byte[] ComputeHashBytes(ReadOnlySpan data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed).ToBytes(); - } - } - - /// - /// Compute hash bytes for the string - /// - /// The source of data - /// The seed number - /// hash - public static unsafe byte[] ComputeHashBytes(string str, ulong seed = 0) - { - Debug.Assert(str != null); - - fixed (char* c = str) - { - byte* ptr = (byte*) c; - int length = str.Length * 2; - - return UnsafeComputeHash(ptr, length, seed).ToBytes(); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint128 UnsafeComputeHash(byte* input, int len, ulong seed) - { - fixed (byte* secret = &XXH3_SECRET[0]) - { - return XXH3_128bits_internal(input, len, seed, secret, XXH3_SECRET_DEFAULT_SIZE); - } - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct uint128 - { - public ulong low64; - public ulong high64; - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash128.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash128.cs.meta deleted file mode 100644 index 464fe0f..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash128.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1ea51d2884ca3b94baf4305ff37b0fcb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH.cs b/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH.cs deleted file mode 100644 index bcd5820..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH.cs +++ /dev/null @@ -1,118 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash3 - { - private static readonly ulong XXH_PRIME64_1 = 11400714785074694791UL; - private static readonly ulong XXH_PRIME64_2 = 14029467366897019727UL; - private static readonly ulong XXH_PRIME64_3 = 1609587929392839161UL; - private static readonly ulong XXH_PRIME64_4 = 9650029242287828579UL; - private static readonly ulong XXH_PRIME64_5 = 2870177450012600261UL; - - private static readonly uint XXH_PRIME32_1 = 2654435761U; - private static readonly uint XXH_PRIME32_2 = 2246822519U; - private static readonly uint XXH_PRIME32_3 = 3266489917U; - private static readonly uint XXH_PRIME32_4 = 668265263U; - private static readonly uint XXH_PRIME32_5 = 374761393U; - - private static readonly int XXH_STRIPE_LEN = 64; - private static readonly int XXH_ACC_NB = XXH_STRIPE_LEN / 8; - private static readonly int XXH_SECRET_CONSUME_RATE = 8; - private static readonly int XXH_SECRET_DEFAULT_SIZE = 192; - private static readonly int XXH_SECRET_MERGEACCS_START = 11; - private static readonly int XXH_SECRET_LASTACC_START = 7; - - private static readonly byte MM_SHUFFLE_0_3_0_1 = 0b0011_0001; - private static readonly byte MM_SHUFFLE_1_0_3_2 = 0b0100_1110; - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH_readLE64(byte* ptr) - { - return *(ulong*) ptr; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint XXH_readLE32(byte* ptr) - { - return *(uint*) ptr; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_swap64(ulong x) - { - return ((x << 56) & 0xff00000000000000UL) | - ((x << 40) & 0x00ff000000000000UL) | - ((x << 24) & 0x0000ff0000000000UL) | - ((x << 8) & 0x000000ff00000000UL) | - ((x >> 8) & 0x00000000ff000000UL) | - ((x >> 24) & 0x0000000000ff0000UL) | - ((x >> 40) & 0x000000000000ff00UL) | - ((x >> 56) & 0x00000000000000ffUL); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_mult32to64(ulong x, ulong y) - { - return (ulong) (uint) (x) * (ulong) (uint) (y); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_xorshift64(ulong v64, int shift) - { - return v64 ^ (v64 >> shift); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint XXH_swap32(uint x) - { - return ((x << 24) & 0xff000000) | - ((x << 8) & 0x00ff0000) | - ((x >> 8) & 0x0000ff00) | - ((x >> 24) & 0x000000ff); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_rotl64(ulong x, int r) - { - return (x << r) | (x >> (64 - r)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH_writeLE64(byte* dst, ulong v64) - { - *(ulong*) dst = v64; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint128 XXH_mult64to128(ulong lhs, ulong rhs) - { - - - return XXH_mult64to128_scalar(lhs, rhs); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint128 XXH_mult64to128_scalar(ulong lhs, ulong rhs) - { - ulong lo_lo = XXH_mult32to64(lhs & 0xFFFFFFFF, rhs & 0xFFFFFFFF); - ulong hi_lo = XXH_mult32to64(lhs >> 32, rhs & 0xFFFFFFFF); - ulong lo_hi = XXH_mult32to64(lhs & 0xFFFFFFFF, rhs >> 32); - ulong hi_hi = XXH_mult32to64(lhs >> 32, rhs >> 32); - - ulong cross = (lo_lo >> 32) + (hi_lo & 0xFFFFFFFF) + lo_hi; - ulong upper = (hi_lo >> 32) + (cross >> 32) + hi_hi; - ulong lower = (cross << 32) | (lo_lo & 0xFFFFFFFF); - - uint128 r128; - r128.low64 = lower; - r128.high64 = upper; - return r128; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH.cs.meta deleted file mode 100644 index 77f0bc6..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 93e944ab70a22e948a6bc0ef5de471c3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH3.cs b/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH3.cs deleted file mode 100644 index 6ef2b0c..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH3.cs +++ /dev/null @@ -1,368 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash3 - { - private static readonly byte[] XXH3_SECRET = - { - 0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c, - 0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f, - 0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21, - 0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c, - 0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3, - 0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8, - 0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d, - 0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64, - 0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb, - 0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e, - 0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce, - 0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e, - }; - - private static readonly ulong[] XXH3_INIT_ACC = - { - XXH_PRIME32_3, XXH_PRIME64_1, XXH_PRIME64_2, XXH_PRIME64_3, - XXH_PRIME64_4, XXH_PRIME32_2, XXH_PRIME64_5, XXH_PRIME32_1 - }; - - private static readonly int XXH3_MIDSIZE_MAX = 240; - private static readonly int XXH3_MIDSIZE_STARTOFFSET = 3; - private static readonly int XXH3_MIDSIZE_LASTOFFSET = 17; - private static readonly int XXH3_SECRET_SIZE_MIN = 136; - private static readonly int XXH3_SECRET_DEFAULT_SIZE = 192; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_64bits_internal(byte* input, int len, ulong seed64, byte* secret, - int secretLen) - { - if (len <= 16) - return XXH3_len_0to16_64b(input, len, secret, seed64); - if (len <= 128) - return XXH3_len_17to128_64b(input, len, secret, secretLen, seed64); - if (len <= XXH3_MIDSIZE_MAX) - return XXH3_len_129to240_64b(input, len, secret, secretLen, seed64); - - return XXH3_hashLong_64b_withSeed(input, len, seed64, secret, secretLen); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_len_0to16_64b(byte* input, int len, byte* secret, ulong seed) - { - if (len > 8) - return XXH3_len_9to16_64b(input, len, secret, seed); - if (len >= 4) - return XXH3_len_4to8_64b(input, len, secret, seed); - if (len != 0) - return XXH3_len_1to3_64b(input, len, secret, seed); - - return XXH64_avalanche(seed ^ (XXH_readLE64(secret + 56) ^ XXH_readLE64(secret + 64))); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_len_9to16_64b(byte* input, int len, byte* secret, ulong seed) - { - ulong bitflip1 = (XXH_readLE64(secret + 24) ^ XXH_readLE64(secret + 32)) + seed; - ulong bitflip2 = (XXH_readLE64(secret + 40) ^ XXH_readLE64(secret + 48)) - seed; - ulong input_lo = XXH_readLE64(input) ^ bitflip1; - ulong input_hi = XXH_readLE64(input + len - 8) ^ bitflip2; - ulong acc = ((ulong) len) - + XXH_swap64(input_lo) + input_hi - + XXH3_mul128_fold64(input_lo, input_hi); - return XXH3_avalanche(acc); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH3_mul128_fold64(ulong lhs, ulong rhs) - { - uint128 product = XXH_mult64to128(lhs, rhs); - return product.low64 ^ product.high64; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH3_avalanche(ulong h64) - { - h64 = XXH_xorshift64(h64, 37); - h64 *= 0x165667919E3779F9UL; - h64 = XXH_xorshift64(h64, 32); - return h64; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_len_4to8_64b(byte* input, int len, byte* secret, ulong seed) - { - seed ^= (ulong) XXH_swap32((uint) seed) << 32; - { - uint input1 = XXH_readLE32(input); - uint input2 = XXH_readLE32(input + len - 4); - ulong bitflip = (XXH_readLE64(secret + 8) ^ XXH_readLE64(secret + 16)) - seed; - ulong input64 = input2 + (((ulong) input1) << 32); - ulong keyed = input64 ^ bitflip; - return XXH3_rrmxmx(keyed, len); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH3_rrmxmx(ulong h64, int len) - { - h64 ^= XXH_rotl64(h64, 49) ^ XXH_rotl64(h64, 24); - h64 *= 0x9FB21C651E98DF25UL; - h64 ^= (h64 >> 35) + (ulong) len; - h64 *= 0x9FB21C651E98DF25UL; - return XXH_xorshift64(h64, 28); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_len_1to3_64b(byte* input, int len, byte* secret, ulong seed) - { - byte c1 = input[0]; - byte c2 = input[len >> 1]; - byte c3 = input[len - 1]; - uint combined = ((uint) c1 << 16) | - ((uint) c2 << 24) | - ((uint) c3 << 0) | - ((uint) len << 8); - - ulong bitflip = (XXH_readLE32(secret) ^ - XXH_readLE32(secret + 4)) + seed; - - ulong keyed = (ulong)combined ^ bitflip; - return XXH64_avalanche(keyed); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_len_17to128_64b(byte* input, int len, byte* secret, int secretSize, ulong seed) - { - ulong acc = ((ulong)len) * XXH_PRIME64_1; - - if (len > 32) - { - if (len > 64) - { - if (len > 96) - { - acc += XXH3_mix16B(input + 48, secret + 96, seed); - acc += XXH3_mix16B(input + len - 64, secret + 112, seed); - } - acc += XXH3_mix16B(input + 32, secret + 64, seed); - acc += XXH3_mix16B(input + len - 48, secret + 80, seed); - } - acc += XXH3_mix16B(input + 16, secret + 32, seed); - acc += XXH3_mix16B(input + len - 32, secret + 48, seed); - } - - acc += XXH3_mix16B(input + 0, secret + 0, seed); - acc += XXH3_mix16B(input + len - 16, secret + 16, seed); - return XXH3_avalanche(acc); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_mix16B(byte* input, byte* secret, ulong seed64) - { - ulong input_lo = XXH_readLE64(input); - ulong input_hi = XXH_readLE64(input + 8); - - return XXH3_mul128_fold64( - input_lo ^ (XXH_readLE64(secret) + seed64), - input_hi ^ (XXH_readLE64(secret + 8) - seed64) - ); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_len_129to240_64b(byte* input, int len, byte* secret, int secretSize, - ulong seed) - { - ulong acc = ((ulong) len) * XXH_PRIME64_1; - int nbRounds = len / 16; - - for (int i = 0; i < 8; i++) - { - acc += XXH3_mix16B(input + (16 * i), secret + (16 * i), seed); - } - acc = XXH3_avalanche(acc); - - for (int i = 8; i < nbRounds; i++) - { - acc += XXH3_mix16B(input + (16 * i), secret + (16 * (i - 8)) + XXH3_MIDSIZE_STARTOFFSET, seed); - } - - acc += XXH3_mix16B(input + len - 16, secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET, seed); - return XXH3_avalanche(acc); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_hashLong_64b_withSeed(byte* input, int len, ulong seed, byte* secret, - int secretSize) - { - if (seed == 0) - return XXH3_hashLong_64b_internal(input, len, secret, secretSize); - - byte* customSecret = stackalloc byte[XXH3_SECRET_DEFAULT_SIZE]; - - XXH3_initCustomSecret(customSecret, seed); - - return XXH3_hashLong_64b_internal(input, len, customSecret, XXH3_SECRET_DEFAULT_SIZE); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_initCustomSecret(byte* customSecret, ulong seed) - { - XXH3_initCustomSecret_scalar(customSecret, seed); - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_initCustomSecret_scalar(byte* customSecret, ulong seed) - { - fixed (byte* kSecretPtr = &XXH3_SECRET[0]) - { - int nbRounds = XXH_SECRET_DEFAULT_SIZE / 16; - - for (int i = 0; i < nbRounds; i++) - { - ulong lo = XXH_readLE64(kSecretPtr + 16 * i) + seed; - ulong hi = XXH_readLE64(kSecretPtr + 16 * i + 8) - seed; - XXH_writeLE64((byte*) customSecret + 16 * i, lo); - XXH_writeLE64((byte*) customSecret + 16 * i + 8, hi); - } - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_hashLong_64b_internal(byte* input, int len, byte* secret, int secretSize) - { - fixed (ulong* src = &XXH3_INIT_ACC[0]) - { - ulong* acc = stackalloc ulong[8] - { - *(src + 0), - *(src + 1), - *(src + 2), - *(src + 3), - *(src + 4), - *(src + 5), - *(src + 6), - *(src + 7), - }; - - XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize); - - return XXH3_mergeAccs(acc, secret + XXH_SECRET_MERGEACCS_START, ((ulong)len) * XXH_PRIME64_1); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_mergeAccs(ulong* acc, byte* secret, ulong start) - { - ulong result64 = start; - - for (int i = 0; i < 4; i++) - result64 += XXH3_mix2Accs(acc + 2 * i, secret + 16 * i); - - return XXH3_avalanche(result64); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH3_mix2Accs(ulong* acc, byte* secret) - { - return XXH3_mul128_fold64( - acc[0] ^ XXH_readLE64(secret), - acc[1] ^ XXH_readLE64(secret + 8)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_hashLong_internal_loop(ulong* acc, byte* input, int len, byte* secret, - int secretSize) - { - int nbStripesPerBlock = (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; - int block_len = XXH_STRIPE_LEN * nbStripesPerBlock; - int nb_blocks = (len - 1) / block_len; - - for (int n = 0; n < nb_blocks; n++) - { - XXH3_accumulate(acc, input + n * block_len, secret, nbStripesPerBlock); - XXH3_scrambleAcc(acc, secret + secretSize - XXH_STRIPE_LEN); - } - - int nbStripes = ((len - 1) - (block_len * nb_blocks)) / XXH_STRIPE_LEN; - XXH3_accumulate(acc, input + nb_blocks * block_len, secret, nbStripes); - - byte* p = input + len - XXH_STRIPE_LEN; - XXH3_accumulate_512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_accumulate(ulong* acc, byte* input, byte* secret, int nbStripes) - { - for (int n = 0; n < nbStripes; n++) - { - byte* inp = input + n * XXH_STRIPE_LEN; - XXH3_accumulate_512(acc, inp, secret + n * XXH_SECRET_CONSUME_RATE); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_accumulate_512(ulong* acc, byte* input, byte* secret) - { - XXH3_accumulate_512_scalar(acc, input, secret); - - } - - - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_accumulate_512_scalar(ulong* acc, byte* input, byte* secret) - { - for (int i = 0; i < XXH_ACC_NB; i++) - XXH3_scalarRound(acc, input, secret, i); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scalarRound(ulong* acc, byte* input, byte* secret, int lane) - { - ulong* xacc = acc; - byte* xinput = input; - byte* xsecret = secret; - - ulong data_val = XXH_readLE64(xinput + lane * 8); - ulong data_key = data_val ^ XXH_readLE64(xsecret + lane * 8); - xacc[lane ^ 1] += data_val; - xacc[lane] += XXH_mult32to64(data_key & 0xFFFFFFFF, data_key >> 32); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scrambleAcc(ulong* acc, byte* secret) - { - XXH3_scrambleAcc_scalar(acc, secret); - - } - - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scrambleAcc_scalar(ulong* acc, byte* secret) - { - for (int i = 0; i < XXH_ACC_NB; i++) - XXH3_scalarScrambleRound(acc, secret, i); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe void XXH3_scalarScrambleRound(ulong* acc, byte* secret, int lane) - { - ulong* xacc = acc; - byte* xsecret = secret; - - ulong key64 = XXH_readLE64(xsecret + lane * 8); - ulong acc64 = xacc[lane]; - acc64 = XXH_xorshift64(acc64, 47); - acc64 ^= key64; - acc64 *= XXH_PRIME32_1; - xacc[lane] = acc64; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH3.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH3.cs.meta deleted file mode 100644 index 4b9f844..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH3.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 04c10c3dcad63224fab3244c585bc4e4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH64.cs b/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH64.cs deleted file mode 100644 index 4450c06..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH64.cs +++ /dev/null @@ -1,20 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash3 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH64_avalanche(ulong hash) - { - hash ^= hash >> 33; - hash *= XXH_PRIME64_2; - hash ^= hash >> 29; - hash *= XXH_PRIME64_3; - hash ^= hash >> 32; - return hash; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH64.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH64.cs.meta deleted file mode 100644 index 5c8eadb..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.XXH64.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6b73a0fcfb28bb44b8d7ce7bb03436a0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.cs b/Assets/YooAsset/Runtime/xxHash/xxHash3.cs deleted file mode 100644 index 6f27344..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.cs +++ /dev/null @@ -1,96 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash3 - { - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe ulong ComputeHash(byte[] data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe ulong ComputeHash(Span data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe ulong ComputeHash(ReadOnlySpan data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* ptr = &data[0]) - { - return UnsafeComputeHash(ptr, length, seed); - } - } - - /// - /// Compute xxHash for the string - /// - /// The source of data - /// The seed number - /// hash - public static unsafe ulong ComputeHash(string unicode, ulong seed = 0) - { - Debug.Assert(unicode != null); - - fixed (char* c = unicode) - { - byte* ptr = (byte*) c; - int length = unicode.Length * 2; - - return UnsafeComputeHash(ptr, length, seed); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong UnsafeComputeHash(byte* input, int len, ulong seed) - { - fixed (byte* secret = &XXH3_SECRET[0]) - { - return XXH3_64bits_internal(input, len, seed, secret, XXH3_SECRET_DEFAULT_SIZE); - } - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash3.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash3.cs.meta deleted file mode 100644 index fa30d22..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash3.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a61e53921f712184a91693b7937b53fb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH.cs b/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH.cs deleted file mode 100644 index 631fd74..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH.cs +++ /dev/null @@ -1,21 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash32 - { - private static readonly uint XXH_PRIME32_1 = 2654435761U; - private static readonly uint XXH_PRIME32_2 = 2246822519U; - private static readonly uint XXH_PRIME32_3 = 3266489917U; - private static readonly uint XXH_PRIME32_4 = 668265263U; - private static readonly uint XXH_PRIME32_5 = 374761393U; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint XXH_rotl32(uint x, int r) - { - return (x << r) | (x >> (32 - r)); - } - } -} diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH.cs.meta deleted file mode 100644 index 1364459..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1c5bf48410ae0d74f8803b0b407b8af5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH32.cs b/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH32.cs deleted file mode 100644 index 1ca5c9c..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH32.cs +++ /dev/null @@ -1,90 +0,0 @@ -// ReSharper disable InconsistentNaming - -namespace Standart.Hash.xxHash -{ - using System.Runtime.CompilerServices; - - public static partial class xxHash32 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint XXH32(byte* input, int len, uint seed) - { - uint h32; - - if (len >= 16) - { - byte* end = input + len; - byte* limit = end - 15; - - uint v1 = seed + XXH_PRIME32_1 + XXH_PRIME32_2; - uint v2 = seed + XXH_PRIME32_2; - uint v3 = seed + 0; - uint v4 = seed - XXH_PRIME32_1; - - do - { - v1 = XXH32_round(v1, *(uint*) input); input += 4; - v2 = XXH32_round(v2, *(uint*) input); input += 4; - v3 = XXH32_round(v3, *(uint*) input); input += 4; - v4 = XXH32_round(v4, *(uint*) input); input += 4; - } while (input < limit); - - h32 = XXH_rotl32(v1, 1) + - XXH_rotl32(v2, 7) + - XXH_rotl32(v3, 12) + - XXH_rotl32(v4, 18); - } - else - { - h32 = seed + XXH_PRIME32_5; - } - - h32 += (uint)len; - - return XXH32_finalize(h32, input, len); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint XXH32_round(uint acc, uint input) - { - acc += input * XXH_PRIME32_2; - acc = XXH_rotl32(acc, 13); - acc *= XXH_PRIME32_1; - return acc; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static uint XXH32_avalanche(uint hash) - { - hash ^= hash >> 15; - hash *= XXH_PRIME32_2; - hash ^= hash >> 13; - hash *= XXH_PRIME32_3; - hash ^= hash >> 16; - return hash; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint XXH32_finalize(uint hash, byte* ptr, int len) - { - len &= 15; - while (len >= 4) - { - hash += *((uint*)ptr) * XXH_PRIME32_3; - ptr += 4; - hash = XXH_rotl32(hash, 17) * XXH_PRIME32_4; - len -= 4; - } - - while (len > 0) - { - hash += *((byte*)ptr) * XXH_PRIME32_5; - ptr++; - hash = XXH_rotl32(hash, 11) * XXH_PRIME32_1; - len--; - } - - return XXH32_avalanche(hash); - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH32.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH32.cs.meta deleted file mode 100644 index 10e2691..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash32.XXH32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 72917bf63cde5cb4a83abbbf562a684a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash32.cs b/Assets/YooAsset/Runtime/xxHash/xxHash32.cs deleted file mode 100644 index e0c4653..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash32.cs +++ /dev/null @@ -1,265 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System; -using System.Buffers; -using System.Diagnostics; -using System.IO; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash32 - { - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe uint ComputeHash(byte[] data, int length, uint seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* pData = &data[0]) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The offset of the data for hashing - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe uint ComputeHash(byte[] data, int offset, int length, uint seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(offset < data.Length); - Debug.Assert(length <= data.Length - offset); - - fixed (byte* pData = &data[0 + offset]) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The seed number - /// hash - public static ulong ComputeHash(ArraySegment data, uint seed = 0) - { - Debug.Assert(data != null); - - return ComputeHash(data.Array, data.Offset, data.Count, seed); - } - - /// - /// Compute xxHash for the async stream - /// - /// The stream of data - /// The buffer size - /// The seed number - /// The hash - public static async ValueTask ComputeHashAsync(Stream stream, int bufferSize = 4096, uint seed = 0) - { - return await ComputeHashAsync(stream, bufferSize, seed, CancellationToken.None); - } - - /// - /// Compute xxHash for the async stream - /// - /// The stream of data - /// The buffer size - /// The seed number - /// The cancellation token - /// The hash - public static async ValueTask ComputeHashAsync(Stream stream, int bufferSize, uint seed, CancellationToken cancellationToken) - { - Debug.Assert(stream != null); - Debug.Assert(bufferSize > 16); - - // Optimizing memory allocation - byte[] buffer = ArrayPool.Shared.Rent(bufferSize + 16); - - int readBytes; - int offset = 0; - long length = 0; - - // Prepare the seed vector - uint v1 = seed + XXH_PRIME32_1 + XXH_PRIME32_2; - uint v2 = seed + XXH_PRIME32_2; - uint v3 = seed + 0; - uint v4 = seed - XXH_PRIME32_1; - - try - { - // Read flow of bytes - while ((readBytes = - await stream.ReadAsync(buffer, offset, bufferSize, cancellationToken).ConfigureAwait(false)) > 0) - { - length = length + readBytes; - offset = offset + readBytes; - - if (offset < 16) continue; - - int r = offset % 16; // remain - int l = offset - r; // length - - // Process the next chunk - __inline__XXH32_stream_process(buffer, l, ref v1, ref v2, ref v3, ref v4); - - // Put remaining bytes to buffer - Utils.BlockCopy(buffer, l, buffer, 0, r); - offset = r; - } - - // Process the final chunk - uint h32 = __inline__XXH32_stream_finalize(buffer, offset, ref v1, ref v2, ref v3, ref v4, length, seed); - - return h32; - } - finally - { - // Free memory - ArrayPool.Shared.Return(buffer); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe uint ComputeHash(Span data, int length, uint seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* pData = &MemoryMarshal.GetReference(data)) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe uint ComputeHash(ReadOnlySpan data, int length, uint seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* pData = &MemoryMarshal.GetReference(data)) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the stream - /// - /// The stream of data - /// The buffer size - /// The seed number - /// The hash - public static uint ComputeHash(Stream stream, int bufferSize = 4096, uint seed = 0) - { - Debug.Assert(stream != null); - Debug.Assert(bufferSize > 16); - - // Optimizing memory allocation - byte[] buffer = ArrayPool.Shared.Rent(bufferSize + 16); - - int readBytes; - int offset = 0; - long length = 0; - - // Prepare the seed vector - uint v1 = seed + XXH_PRIME32_1 + XXH_PRIME32_2; - uint v2 = seed + XXH_PRIME32_2; - uint v3 = seed + 0; - uint v4 = seed - XXH_PRIME32_1; - - try - { - // Read flow of bytes - while ((readBytes = stream.Read(buffer, offset, bufferSize)) > 0) - { - length = length + readBytes; - offset = offset + readBytes; - - if (offset < 16) continue; - - int r = offset % 16; // remain - int l = offset - r; // length - - // Process the next chunk - __inline__XXH32_stream_process(buffer, l, ref v1, ref v2, ref v3, ref v4); - - // Put remaining bytes to buffer - Utils.BlockCopy(buffer, l, buffer, 0, r); - offset = r; - } - - // Process the last chunk - uint h32 = __inline__XXH32_stream_finalize(buffer, offset, ref v1, ref v2, ref v3, ref v4, length, seed); - - return h32; - } - finally - { - // Free memory - ArrayPool.Shared.Return(buffer); - } - } - - /// - /// Compute xxHash for the string - /// - /// The source of data - /// The seed number - /// hash - public static unsafe uint ComputeHash(string str, uint seed = 0) - { - Debug.Assert(str != null); - - fixed (char* c = str) - { - byte* ptr = (byte*) c; - int length = str.Length * 2; - - return UnsafeComputeHash(ptr, length, seed); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe uint UnsafeComputeHash(byte* ptr, int length, uint seed) - { - // Use inlined version - // return XXH32(ptr, length, seed); - - return __inline__XXH32(ptr, length, seed); - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash32.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash32.cs.meta deleted file mode 100644 index 7dd9481..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 877a8f61386aaf044bb5b0876d759d3e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH.cs b/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH.cs deleted file mode 100644 index dafbed8..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH.cs +++ /dev/null @@ -1,21 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System.Runtime.CompilerServices; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash64 - { - private static readonly ulong XXH_PRIME64_1 = 11400714785074694791UL; - private static readonly ulong XXH_PRIME64_2 = 14029467366897019727UL; - private static readonly ulong XXH_PRIME64_3 = 1609587929392839161UL; - private static readonly ulong XXH_PRIME64_4 = 9650029242287828579UL; - private static readonly ulong XXH_PRIME64_5 = 2870177450012600261UL; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH_rotl64(ulong x, int r) - { - return (x << r) | (x >> (64 - r)); - } - } -} diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH.cs.meta deleted file mode 100644 index 47ee835..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 519eafbf3455e3c4e8a3cee3051367ad -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH64.cs b/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH64.cs deleted file mode 100644 index 5c04f8f..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH64.cs +++ /dev/null @@ -1,106 +0,0 @@ -// ReSharper disable InconsistentNaming - -namespace Standart.Hash.xxHash -{ - using System.Runtime.CompilerServices; - - public static partial class xxHash64 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH64(byte* input, int len, ulong seed) - { - ulong h64; - - if (len >= 32) - { - byte* end = input + len; - byte* limit = end - 31; - - ulong v1 = seed + XXH_PRIME64_1 + XXH_PRIME64_2; - ulong v2 = seed + XXH_PRIME64_2; - ulong v3 = seed + 0; - ulong v4 = seed - XXH_PRIME64_1; - - do - { - v1 = XXH64_round(v1, *(ulong*) input); input += 8; - v2 = XXH64_round(v2, *(ulong*) input); input += 8; - v3 = XXH64_round(v3, *(ulong*) input); input += 8; - v4 = XXH64_round(v4, *(ulong*) input); input += 8; - } while (input < limit); - - h64 = XXH_rotl64(v1, 1) + - XXH_rotl64(v2, 7) + - XXH_rotl64(v3, 12) + - XXH_rotl64(v4, 18); - - h64 = XXH64_mergeRound(h64, v1); - h64 = XXH64_mergeRound(h64, v2); - h64 = XXH64_mergeRound(h64, v3); - h64 = XXH64_mergeRound(h64, v4); - } - else - { - h64 = seed + XXH_PRIME64_5; - } - - h64 += (ulong)len; - - return XXH64_finalize(h64, input, len); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH64_round(ulong acc, ulong input) - { - acc += input * XXH_PRIME64_2; - acc = XXH_rotl64(acc, 31); - acc *= XXH_PRIME64_1; - return acc; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH64_mergeRound(ulong acc, ulong val) - { - val = XXH64_round(0, val); - acc ^= val; - acc = acc * XXH_PRIME64_1 + XXH_PRIME64_4; - return acc; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static ulong XXH64_avalanche(ulong hash) - { - hash ^= hash >> 33; - hash *= XXH_PRIME64_2; - hash ^= hash >> 29; - hash *= XXH_PRIME64_3; - hash ^= hash >> 32; - return hash; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong XXH64_finalize(ulong hash, byte* ptr, int len) - { - len &= 31; - while (len >= 8) { - ulong k1 = XXH64_round(0, *(ulong*)ptr); - ptr += 8; - hash ^= k1; - hash = XXH_rotl64(hash,27) * XXH_PRIME64_1 + XXH_PRIME64_4; - len -= 8; - } - if (len >= 4) { - hash ^= *(uint*)ptr * XXH_PRIME64_1; - ptr += 4; - hash = XXH_rotl64(hash, 23) * XXH_PRIME64_2 + XXH_PRIME64_3; - len -= 4; - } - while (len > 0) { - hash ^= (*ptr++) * XXH_PRIME64_5; - hash = XXH_rotl64(hash, 11) * XXH_PRIME64_1; - --len; - } - return XXH64_avalanche(hash); - } - } -} diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH64.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH64.cs.meta deleted file mode 100644 index 1260ef3..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash64.XXH64.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fd708be04cb928d4d8b419a27144213e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash64.cs b/Assets/YooAsset/Runtime/xxHash/xxHash64.cs deleted file mode 100644 index 671a3bc..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash64.cs +++ /dev/null @@ -1,266 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System; -using System.Buffers; -using System.Diagnostics; -using System.IO; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; - -namespace Standart.Hash.xxHash -{ - public static partial class xxHash64 - { - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe ulong ComputeHash(byte[] data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* pData = &data[0]) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe ulong ComputeHash(byte[] data, int offset, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(offset < data.Length); - Debug.Assert(length <= data.Length - offset); - - fixed (byte* pData = &data[0 + offset]) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the data byte array - /// - /// The source of data - /// The seed number - /// hash - public static unsafe ulong ComputeHash(System.ArraySegment data, ulong seed = 0) - { - Debug.Assert(data != null); - - return ComputeHash(data.Array, data.Offset, data.Count, seed); - } - - /// - /// Compute xxHash for the async stream - /// - /// The stream of data - /// The buffer size - /// The seed number - /// The hash - public static async ValueTask ComputeHashAsync(Stream stream, int bufferSize = 8192, ulong seed = 0) - { - return await ComputeHashAsync(stream, bufferSize, seed, CancellationToken.None); - } - - /// - /// Compute xxHash for the async stream - /// - /// The stream of data - /// The buffer size - /// The seed number - /// The cancelation token - /// The hash - public static async ValueTask ComputeHashAsync(Stream stream, int bufferSize, ulong seed, - CancellationToken cancellationToken) - { - Debug.Assert(stream != null); - Debug.Assert(bufferSize > 32); - - // Optimizing memory allocation - byte[] buffer = ArrayPool.Shared.Rent(bufferSize + 32); - - int readBytes; - int offset = 0; - long length = 0; - - // Prepare the seed vector - ulong v1 = seed + XXH_PRIME64_1 + XXH_PRIME64_2; - ulong v2 = seed + XXH_PRIME64_2; - ulong v3 = seed + 0; - ulong v4 = seed - XXH_PRIME64_1; - - try - { - // Read flow of bytes - while ((readBytes = - await stream.ReadAsync(buffer, offset, bufferSize, cancellationToken).ConfigureAwait(false)) > 0) - { - length = length + readBytes; - offset = offset + readBytes; - - if (offset < 32) continue; - - int r = offset % 32; // remain - int l = offset - r; // length - - // Process the next chunk - __inline__XXH64_stream_process(buffer, l, ref v1, ref v2, ref v3, ref v4); - - // Put remaining bytes to buffer - Utils.BlockCopy(buffer, l, buffer, 0, r); - offset = r; - } - - // Process the final chunk - ulong h64 = __inline__XXH64_stream_finalize(buffer, offset, ref v1, ref v2, ref v3, ref v4, length, seed); - - return h64; - } - finally - { - // Free memory - ArrayPool.Shared.Return(buffer); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe ulong ComputeHash(Span data, int length, ulong seed = 0) - { - //Debug.Assert(data != null); - //Debug.Assert(length >= 0); - //Debug.Assert(length <= data.Length); - - fixed (byte* pData = &MemoryMarshal.GetReference(data)) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the data byte span - /// - /// The source of data - /// The length of the data for hashing - /// The seed number - /// hash - public static unsafe ulong ComputeHash(ReadOnlySpan data, int length, ulong seed = 0) - { - Debug.Assert(data != null); - Debug.Assert(length >= 0); - Debug.Assert(length <= data.Length); - - fixed (byte* pData = &MemoryMarshal.GetReference(data)) - { - return UnsafeComputeHash(pData, length, seed); - } - } - - /// - /// Compute xxHash for the stream - /// - /// The stream of data - /// The buffer size - /// The seed number - /// The hash - public static ulong ComputeHash(Stream stream, int bufferSize = 8192, ulong seed = 0) - { - Debug.Assert(stream != null); - Debug.Assert(bufferSize > 32); - - // Optimizing memory allocation - byte[] buffer = ArrayPool.Shared.Rent(bufferSize + 32); - - int readBytes; - int offset = 0; - long length = 0; - - // Prepare the seed vector - ulong v1 = seed + XXH_PRIME64_1 + XXH_PRIME64_2; - ulong v2 = seed + XXH_PRIME64_2; - ulong v3 = seed + 0; - ulong v4 = seed - XXH_PRIME64_1; - - try - { - // Read flow of bytes - while ((readBytes = stream.Read(buffer, offset, bufferSize)) > 0) - { - length = length + readBytes; - offset = offset + readBytes; - - if (offset < 32) continue; - - int r = offset % 32; // remain - int l = offset - r; // length - - // Process the next chunk - __inline__XXH64_stream_process(buffer, l, ref v1, ref v2, ref v3, ref v4); - - // Put remaining bytes to buffer - Utils.BlockCopy(buffer, l, buffer, 0, r); - offset = r; - } - - // Process the final chunk - ulong h64 = __inline__XXH64_stream_finalize(buffer, offset, ref v1, ref v2, ref v3, ref v4, length, seed); - - return h64; - } - finally - { - // Free memory - ArrayPool.Shared.Return(buffer); - } - } - - /// - /// Compute xxHash for the string - /// - /// The source of data - /// The seed number - /// hash - public static unsafe ulong ComputeHash(string str, uint seed = 0) - { - Debug.Assert(str != null); - - fixed (char* c = str) - { - byte* ptr = (byte*) c; - int length = str.Length * 2; - - return UnsafeComputeHash(ptr, length, seed); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe ulong UnsafeComputeHash(byte* ptr, int length, ulong seed) - { - // Use inlined version - // return XXH64(ptr, length, seed); - - return __inline__XXH64(ptr, length, seed); - } - } -} - diff --git a/Assets/YooAsset/Runtime/xxHash/xxHash64.cs.meta b/Assets/YooAsset/Runtime/xxHash/xxHash64.cs.meta deleted file mode 100644 index 9c31ef9..0000000 --- a/Assets/YooAsset/Runtime/xxHash/xxHash64.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2ca6cc6a152389145bc1ef4f745d636e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: