提交 0f720e00 编写于 作者: cdy816's avatar cdy816

优化无损压缩算法,提高压缩速度

上级 b56c8324
//==============================================================
// Copyright (C) 2020 Inc. All rights reserved.
//
//==============================================================
// Create by 种道洋 at 2020/5/23 23:58:40.
// Version 1.0
// 种道洋
//==============================================================
using System;
using System.Collections.Generic;
using System.Text;
namespace Cdy.Tag
{
public class CustomQueue<T>
{
#region ... Variables ...
private T[] mColections;
private int mCount = 0;
#endregion ...Variables...
#region ... Events ...
#endregion ...Events...
#region ... Constructor...
/// <summary>
///
/// </summary>
/// <param name="count"></param>
public CustomQueue(int count)
{
mColections = new T[count];
mCount = count;
}
#endregion ...Constructor...
#region ... Properties ...
public int Index { get; set; }
#endregion ...Properties...
#region ... Methods ...
/// <summary>
///
/// </summary>
/// <param name="value"></param>
public void Insert(T value)
{
Index++;
mColections[Index] = value;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public T Remove()
{
Index--;
if (Index < 0)
{
Index = -1;
return default(T);
}
else
{
return mColections[Index];
}
}
public T Get(int index)
{
return mColections[index];
}
#endregion ...Methods...
#region ... Interfaces ...
#endregion ...Interfaces...
}
}
...@@ -47,7 +47,7 @@ namespace Cdy.Tag ...@@ -47,7 +47,7 @@ namespace Cdy.Tag
private object mUserSizeLock = new object(); private object mUserSizeLock = new object();
public int BufferItemSize = 1024 * 1024 * 128; public int BufferItemSize = 1024 * 1024 * 4;
public static byte[] zoreData = new byte[1024 * 10]; public static byte[] zoreData = new byte[1024 * 10];
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Cdy.Tag\Cdy.Tag.csproj" /> <ProjectReference Include="..\Cdy.Tag\Cdy.Tag.csproj" />
</ItemGroup> </ItemGroup>
......
...@@ -26,11 +26,18 @@ namespace Cdy.Tag ...@@ -26,11 +26,18 @@ namespace Cdy.Tag
/// </summary> /// </summary>
private Dictionary<int, CompressUnitbase> mCompressUnit = new Dictionary<int, CompressUnitbase>(); private Dictionary<int, CompressUnitbase> mCompressUnit = new Dictionary<int, CompressUnitbase>();
/// <summary>
///
/// </summary>
private Dictionary<int, Queue<CompressUnitbase>> mPoolCompressUnits = new Dictionary<int, Queue<CompressUnitbase>>();
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public static CompressUnitManager Manager = new CompressUnitManager(); public static CompressUnitManager Manager = new CompressUnitManager();
#endregion ...Variables... #endregion ...Variables...
#region ... Events ... #region ... Events ...
...@@ -54,7 +61,52 @@ namespace Cdy.Tag ...@@ -54,7 +61,52 @@ namespace Cdy.Tag
/// <returns></returns> /// <returns></returns>
public CompressUnitbase GetCompress(int type) public CompressUnitbase GetCompress(int type)
{ {
return mCompressUnit.ContainsKey(type) ? mCompressUnit[type] : null; lock (mPoolCompressUnits)
{
if (mCompressUnit.ContainsKey(type))
{
if (mPoolCompressUnits.ContainsKey(type) && mPoolCompressUnits[type].Count > 0)
{
return mPoolCompressUnits[type].Dequeue();
}
else
{
return mCompressUnit[type].Clone();
}
}
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public CompressUnitbase GetCompressQuick(int type)
{
return mCompressUnit.ContainsKey(type)?mCompressUnit[type]:null;
}
/// <summary>
///
/// </summary>
/// <param name="compress"></param>
public void ReleaseCompress(CompressUnitbase compress)
{
lock (mPoolCompressUnits)
{
if (mPoolCompressUnits.ContainsKey(compress.TypeCode))
{
mPoolCompressUnits[compress.TypeCode].Enqueue(compress);
}
else
{
var dd = new Queue<CompressUnitbase>();
dd.Enqueue(compress);
mPoolCompressUnits.Add(compress.TypeCode, dd);
}
}
} }
/// <summary> /// <summary>
......
...@@ -91,6 +91,7 @@ namespace Cdy.Tag ...@@ -91,6 +91,7 @@ namespace Cdy.Tag
#region ... Methods ... #region ... Methods ...
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
......
...@@ -838,6 +838,95 @@ namespace Cdy.Tag ...@@ -838,6 +838,95 @@ namespace Cdy.Tag
AddPoint(value.X, value.Y, value.Z, time, qulity); AddPoint(value.X, value.Y, value.Z, time, qulity);
} }
/// <summary>
///
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public T GetValue(int index)
{
object re = null;
switch (mDataType)
{
case 0:
re = Convert.ToBoolean(MemoryHelper.ReadByte((void*)handle, index));
break;
case 1:
re = MemoryHelper.ReadByte((void*)handle, index);
break;
case 2:
re = MemoryHelper.ReadShort((void*)handle, index * 2);
break;
case 3:
re = MemoryHelper.ReadShort((void*)handle, index * 2);
break;
case 4:
re = MemoryHelper.ReadInt32((void*)handle, index * 4);
break;
case 5:
re = MemoryHelper.ReadUInt32((void*)handle, index * 4);
break;
case 6:
re = MemoryHelper.ReadInt64((void*)handle, index * 8);
break;
case 7:
re = MemoryHelper.ReadUInt64((void*)handle, index * 8);
break;
case 8:
re = MemoryHelper.ReadFloat((void*)handle, index * 4);
break;
case 9:
re = MemoryHelper.ReadDouble((void*)handle, index * 8);
break;
case 10:
re = MemoryHelper.ReadDateTime((void*)handle, index * 8);
break;
case 11:
int cc = 0;
int pos = 0;
while (true)
{
if (cc >= index)
{
break;
}
//pos += (mDataBuffer[pos]+1);
pos += MemoryHelper.ReadByte((void*)handle, pos) + 1;
cc++;
}
re = new string((char*)handle, pos + 1, MemoryHelper.ReadByte((void*)handle, pos));
break;
case 12:
var x = MemoryHelper.ReadInt32((void*)handle, index * 8);
var y = MemoryHelper.ReadInt32((void*)handle, index * 8 + 4);
re = new IntPointData(x, y);
break;
case 13:
re = new UIntPointData(MemoryHelper.ReadUInt32((void*)handle, index * 8), MemoryHelper.ReadUInt32((void*)handle, index * 8 + 4));
break;
case 14:
re = new IntPoint3Data(MemoryHelper.ReadInt32((void*)handle, index * 12), MemoryHelper.ReadInt32((void*)handle, index * 12 + 4), MemoryHelper.ReadInt32((void*)handle, index * 12 + 8));
break;
case 15:
re = new UIntPoint3Data(MemoryHelper.ReadUInt32((void*)handle, index * 12), MemoryHelper.ReadUInt32((void*)handle, index * 12 + 4), MemoryHelper.ReadUInt32((void*)handle, index * 12 + 8));
break;
case 16:
re = new LongPointData(MemoryHelper.ReadInt64((void*)handle, index * 16), MemoryHelper.ReadInt64((void*)handle, index * 16 + 8));
break;
case 17:
re = new ULongPointData(MemoryHelper.ReadUInt64((void*)handle, index * 16), MemoryHelper.ReadUInt64((void*)handle, index * 16 + 8));
break;
case 18:
re = new LongPoint3Data(MemoryHelper.ReadInt64((void*)handle, index * 24), MemoryHelper.ReadInt64((void*)handle, index * 24 + 8), MemoryHelper.ReadInt64((void*)handle, index * 24 + 16));
break;
case 19:
re = new ULongPoint3Data(MemoryHelper.ReadUInt64((void*)handle, index * 24), MemoryHelper.ReadUInt64((void*)handle, index * 24 + 8), MemoryHelper.ReadUInt64((void*)handle, index * 24 + 16));
break;
}
return (T)re;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
......
...@@ -396,6 +396,7 @@ namespace DBStudio ...@@ -396,6 +396,7 @@ namespace DBStudio
{ {
StringBuilder re = new StringBuilder(); StringBuilder re = new StringBuilder();
re.AppendLine(); re.AppendLine();
re.AppendLine("save // save database ");
re.AppendLine("start // start database "); re.AppendLine("start // start database ");
re.AppendLine("restart // restart database "); re.AppendLine("restart // restart database ");
re.AppendLine("stop // stop database "); re.AppendLine("stop // stop database ");
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Common\Cdy.Tag.Common\Cdy.Tag.Common.csproj" /> <ProjectReference Include="..\..\Common\Cdy.Tag.Common\Cdy.Tag.Common.csproj" />
<ProjectReference Include="..\..\Common\Cdy.Tag\Cdy.Tag.csproj" /> <ProjectReference Include="..\..\Common\Cdy.Tag\Cdy.Tag.csproj" />
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Common\Cdy.Tag.Common\Cdy.Tag.Common.csproj" /> <ProjectReference Include="..\..\Common\Cdy.Tag.Common\Cdy.Tag.Common.csproj" />
<ProjectReference Include="..\..\Common\Cdy.Tag.Network\Cdy.Tag.Network.csproj" /> <ProjectReference Include="..\..\Common\Cdy.Tag.Network\Cdy.Tag.Network.csproj" />
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Common\Cdy.Tag.Driver\Cdy.Tag.Driver.csproj" /> <ProjectReference Include="..\..\Common\Cdy.Tag.Driver\Cdy.Tag.Driver.csproj" />
<ProjectReference Include="..\..\Common\Cdy.Tag.Network\Cdy.Tag.Network.csproj" /> <ProjectReference Include="..\..\Common\Cdy.Tag.Network\Cdy.Tag.Network.csproj" />
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).XML&quot; copy &quot;$(TargetDir)$(TargetName).XML&quot; &quot;$(SolutionDir)\Output\Xml&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).pdb&quot; copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)Config\*.cfg&quot; &quot;$(SolutionDir)\Output\Config&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)zh-CN&quot; copy &quot;$(TargetDir)zh-CN\*.dll&quot; &quot;$(SolutionDir)\Output\zh-CN&quot; /y&#xD;&#xA;" /> <Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).XML&quot; copy &quot;$(TargetDir)$(TargetName).XML&quot; &quot;$(SolutionDir)\Output\Xml&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).pdb&quot; copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)Config\*.cfg&quot; &quot;$(SolutionDir)\Output\Config&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)zh-CN&quot; copy &quot;$(TargetDir)zh-CN\*.dll&quot; &quot;$(SolutionDir)\Output\zh-CN&quot; /y&#xD;&#xA;" />
</Target> </Target>
......
...@@ -102,7 +102,7 @@ namespace Cdy.Tag ...@@ -102,7 +102,7 @@ namespace Cdy.Tag
} }
} }
long psize = mTotalSize/mTargetMemorys.Count; long psize = (long)(mTotalSize*1.5)/mTargetMemorys.Count;
System.Threading.Tasks.Parallel.ForEach(mTargetMemorys, (vv) => { System.Threading.Tasks.Parallel.ForEach(mTargetMemorys, (vv) => {
vv.Value.ReAlloc(vv.Value.HeadSize + psize); vv.Value.ReAlloc(vv.Value.HeadSize + psize);
......
...@@ -28,6 +28,8 @@ namespace Cdy.Tag ...@@ -28,6 +28,8 @@ namespace Cdy.Tag
private Dictionary<int, Tuple<long, int, int, int>> mTagAddress; private Dictionary<int, Tuple<long, int, int, int>> mTagAddress;
private DateTime mCurrentTime; private DateTime mCurrentTime;
private IHisEngine mHisTagService; private IHisEngine mHisTagService;
private Dictionary<int, CompressUnitbase> mCompressCach = new Dictionary<int, CompressUnitbase>();
private Dictionary<int, long> dtmp = new Dictionary<int, long>();
#endregion ...Variables... #endregion ...Variables...
#region ... Events ... #region ... Events ...
...@@ -67,6 +69,8 @@ namespace Cdy.Tag ...@@ -67,6 +69,8 @@ namespace Cdy.Tag
/// </summary> /// </summary>
public static int TagCountPerMemory { get; set; } public static int TagCountPerMemory { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
...@@ -120,14 +124,15 @@ namespace Cdy.Tag ...@@ -120,14 +124,15 @@ namespace Cdy.Tag
#region ... Methods ... #region ... Methods ...
/// <summary> ///// <summary>
/// /////
/// </summary> ///// </summary>
public void ResetTagAddress() //public void ResetTagAddress()
{ //{
mTagAddress.Clear(); // mTagAddress.Clear();
mTagAddress = null; // mTagAddress = null;
} // mCompressCach.Clear();
//}
/// <summary> /// <summary>
/// ///
...@@ -135,12 +140,20 @@ namespace Cdy.Tag ...@@ -135,12 +140,20 @@ namespace Cdy.Tag
/// <param name="sourceM"></param> /// <param name="sourceM"></param>
private void CheckTagAddress(MergeMemoryBlock sourceM) private void CheckTagAddress(MergeMemoryBlock sourceM)
{ {
if(mTagAddress==null && sourceM!=null)
if (mTagAddress==null && sourceM!=null)
{ {
mTagAddress = new Dictionary<int, Tuple<long, int, int, int>>(); mTagAddress = new Dictionary<int, Tuple<long, int, int, int>>();
dtmp.Clear();
foreach (var vv in sourceM.TagAddress.Where(e=>e.Key>=Id* TagCountPerMemory && e.Key<(Id+1)* TagCountPerMemory)) foreach (var vv in sourceM.TagAddress.Where(e=>e.Key>=Id* TagCountPerMemory && e.Key<(Id+1)* TagCountPerMemory))
{ {
mTagAddress.Add(vv.Key,vv.Value); mTagAddress.Add(vv.Key,vv.Value);
dtmp.Add(vv.Key, 0);
var cpt = mHisTagService.GetHisTag(vv.Key).CompressType;
if(!mCompressCach.ContainsKey(cpt))
{
mCompressCach.Add(cpt, CompressUnitManager.Manager.GetCompressQuick(cpt).Clone());
}
} }
} }
} }
...@@ -165,16 +178,15 @@ namespace Cdy.Tag ...@@ -165,16 +178,15 @@ namespace Cdy.Tag
int headOffset = 4 + 4; int headOffset = 4 + 4;
long Offset = headOffset + this.mTagAddress.Count * 8; long Offset = headOffset + this.mTagAddress.Count * 8;
Dictionary<int, long> dtmp = new Dictionary<int, long>();
this.MakeMemoryBusy(); this.MakeMemoryBusy();
long ltmp1 = sw.ElapsedMilliseconds;
//更新数据区域 //更新数据区域
foreach(var vv in mTagAddress) foreach(var vv in mTagAddress)
{ {
var size = CompressBlockMemory(source, vv.Value.Item1, Offset,vv.Value.Item3, vv.Value.Item4, vv.Key); var size = CompressBlockMemory(source, vv.Value.Item1, Offset,vv.Value.Item3, vv.Value.Item4, vv.Key);
dtmp.Add(vv.Key, Offset); dtmp[vv.Key]= Offset;
Offset += size; Offset += size;
datasize += size; datasize += size;
} }
...@@ -183,6 +195,8 @@ namespace Cdy.Tag ...@@ -183,6 +195,8 @@ namespace Cdy.Tag
this.WriteInt(0,(int)datasize); this.WriteInt(0,(int)datasize);
this.Write((int)this.mTagAddress.Count); this.Write((int)this.mTagAddress.Count);
long ltmp2 = sw.ElapsedMilliseconds;
int count = 0; int count = 0;
foreach (var vv in dtmp) foreach (var vv in dtmp)
{ {
...@@ -191,10 +205,12 @@ namespace Cdy.Tag ...@@ -191,10 +205,12 @@ namespace Cdy.Tag
count+=8; count+=8;
} }
long ltmp3 = sw.ElapsedMilliseconds;
ServiceLocator.Locator.Resolve<IDataSerialize>().RequestToSeriseFile(this, mCurrentTime); ServiceLocator.Locator.Resolve<IDataSerialize>().RequestToSeriseFile(this, mCurrentTime);
sw.Stop(); sw.Stop();
LoggerService.Service.Info("CompressEnginer", Id+ "压缩完成 耗时:"+sw.ElapsedMilliseconds); LoggerService.Service.Info("CompressEnginer", Id+ "压缩完成 耗时:"+sw.ElapsedMilliseconds +" ltmp1:"+ltmp1 +" ltmp2:"+(ltmp2-ltmp1)+" ltmp3:"+(ltmp3-ltmp2),ConsoleColor.Red);
} }
/// <summary> /// <summary>
...@@ -219,12 +235,12 @@ namespace Cdy.Tag ...@@ -219,12 +235,12 @@ namespace Cdy.Tag
var comtype = histag.CompressType;//压缩类型 var comtype = histag.CompressType;//压缩类型
this.CheckAndResize(targetPosition + len); // this.CheckAndResize(targetPosition + len);
//写入压缩类型 //写入压缩类型
this.WriteByte(targetPosition + 4, (byte)comtype); this.WriteByte(targetPosition + 4, (byte)comtype);
var tp = CompressUnitManager.Manager.GetCompress(comtype); var tp = mCompressCach[comtype];
if (tp != null) if (tp != null)
{ {
tp.QulityOffset = (int)qulityoffset; tp.QulityOffset = (int)qulityoffset;
...@@ -235,6 +251,7 @@ namespace Cdy.Tag ...@@ -235,6 +251,7 @@ namespace Cdy.Tag
var size = tp.Compress(mSourceMemory, addr, this, targetPosition + 5, len) + 1; var size = tp.Compress(mSourceMemory, addr, this, targetPosition + 5, len) + 1;
this.WriteInt(targetPosition, (int)size); this.WriteInt(targetPosition, (int)size);
//this.Dump(); //this.Dump();
return size + 5; return size + 5;
} }
......
...@@ -65,7 +65,7 @@ namespace Cdy.Tag ...@@ -65,7 +65,7 @@ namespace Cdy.Tag
/// <param name="count"></param> /// <param name="count"></param>
/// <param name="emptyIds"></param> /// <param name="emptyIds"></param>
/// <returns></returns> /// <returns></returns>
protected override Memory<byte> CompressValues<T>(MarshalMemoryBlock source, long offset, int count, Queue<int> emptyIds) protected override Memory<byte> CompressValues<T>(MarshalMemoryBlock source, long offset, int count, CustomQueue<int> emptys, TagType type)
{ {
var deadArea = this.Parameters.ContainsKey("DeadValue") ? this.Parameters["DeadValue"] : 0; var deadArea = this.Parameters.ContainsKey("DeadValue") ? this.Parameters["DeadValue"] : 0;
var deadType = (int)(this.Parameters.ContainsKey("DeadType") ? this.Parameters["DeadType"] : 0); var deadType = (int)(this.Parameters.ContainsKey("DeadType") ? this.Parameters["DeadType"] : 0);
...@@ -76,7 +76,7 @@ namespace Cdy.Tag ...@@ -76,7 +76,7 @@ namespace Cdy.Tag
bool isFirst = true; bool isFirst = true;
int ig = -1; int ig = -1;
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
if (typeof(T) == typeof(byte)) if (typeof(T) == typeof(byte))
{ {
...@@ -103,8 +103,8 @@ namespace Cdy.Tag ...@@ -103,8 +103,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
return mMarshalMemory.StartMemory.AsMemory<byte>(0, (int)mMarshalMemory.Position); return mMarshalMemory.StartMemory.AsMemory<byte>(0, (int)mMarshalMemory.Position);
...@@ -134,8 +134,8 @@ namespace Cdy.Tag ...@@ -134,8 +134,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
...@@ -165,8 +165,8 @@ namespace Cdy.Tag ...@@ -165,8 +165,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
...@@ -196,8 +196,8 @@ namespace Cdy.Tag ...@@ -196,8 +196,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
...@@ -227,8 +227,8 @@ namespace Cdy.Tag ...@@ -227,8 +227,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
} }
...@@ -257,8 +257,8 @@ namespace Cdy.Tag ...@@ -257,8 +257,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
...@@ -288,8 +288,8 @@ namespace Cdy.Tag ...@@ -288,8 +288,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
...@@ -319,8 +319,8 @@ namespace Cdy.Tag ...@@ -319,8 +319,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
return mMarshalMemory.StartMemory.AsMemory<byte>(0, (int)mMarshalMemory.Position); return mMarshalMemory.StartMemory.AsMemory<byte>(0, (int)mMarshalMemory.Position);
...@@ -350,8 +350,8 @@ namespace Cdy.Tag ...@@ -350,8 +350,8 @@ namespace Cdy.Tag
} }
else else
{ {
if (emptyIds.Count > 0)
emptyIds.TryDequeue(out ig); ig = emptys.Index >= 0 ? emptys.Remove() : -1;
} }
} }
return mMarshalMemory.StartMemory.AsMemory<byte>(0, (int)mMarshalMemory.Position); return mMarshalMemory.StartMemory.AsMemory<byte>(0, (int)mMarshalMemory.Position);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册