Skip to content

Commit

Permalink
refactor: add type-safe array copy function
Browse files Browse the repository at this point in the history
ikpil committed Nov 11, 2023
1 parent a50ba0b commit 69c8c95
Showing 23 changed files with 72 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public bool Contains(T item)
public void CopyTo(T[] array, int arrayIndex)
{
var self = this;
Array.Copy(self._array!, 0, array, arrayIndex, self.Length);
RcArrays.Copy(self._array!, 0, array, arrayIndex, self.Length);
}

public void Add(T item)
2 changes: 1 addition & 1 deletion src/DotRecast.Core/Collections/RcImmutableArray.cs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public static RcImmutableArray<T> Create<T>(params T[] items)
}

var tmp = new T[items.Length];
Array.Copy(items, tmp, items.Length);
RcArrays.Copy(items, tmp, items.Length);
return new RcImmutableArray<T>(tmp);
}
}
10 changes: 5 additions & 5 deletions src/DotRecast.Core/Compression/FastLZ.cs
Original file line number Diff line number Diff line change
@@ -356,7 +356,7 @@ public static long DecompressLevel1(byte[] input, long inputOffset, long length,
return 0;
}

Array.Copy(input, ip, output, op, ctrl);
RcArrays.Copy(input, ip, output, op, ctrl);
ip += ctrl;
op += ctrl;
}
@@ -452,7 +452,7 @@ public static long DecompressLevel2(byte[] input, long inputOffset, long length,
return 0;
}

Array.Copy(input, ip, output, op, ctrl);
RcArrays.Copy(input, ip, output, op, ctrl);
ip += ctrl;
op += ctrl;
}
@@ -498,16 +498,16 @@ public static void SmallCopy(byte[] dest, long destOffset, byte[] src, long srcO
// if (count >= 4)
// {
// count -= count % 4;
// Array.Copy(src, srcOffset, dest, destOffset, count);
// RcArrays.Copy(src, srcOffset, dest, destOffset, count);
// }
Array.Copy(src, srcOffset, dest, destOffset, count);
RcArrays.Copy(src, srcOffset, dest, destOffset, count);
}

// special case of memcpy: exactly MAX_COPY bytes
// flz_maxcopy
static void MaxCopy(byte[] dest, long destOffset, byte[] src, long secOffset)
{
Array.Copy(src, secOffset, dest, destOffset, MAX_COPY);
RcArrays.Copy(src, secOffset, dest, destOffset, MAX_COPY);
}

// flz_literals
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
using System;
using System.Runtime.CompilerServices;

namespace DotRecast.Core
{
public static class RcArrayUtils
public static class RcArrays
{
// Type Safe Copy
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Copy<T>(T[] sourceArray, long sourceIndex, T[] destinationArray, long destinationIndex, long length)
{
Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length);
}

// Type Safe Copy
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Copy<T>(T[] sourceArray, T[] destinationArray, long length)
{
Array.Copy(sourceArray, destinationArray, length);
}

public static T[] CopyOf<T>(T[] source, int startIdx, int length)
{
var deatArr = new T[length];
2 changes: 1 addition & 1 deletion src/DotRecast.Detour.Crowd/DtCrowd.cs
Original file line number Diff line number Diff line change
@@ -1145,7 +1145,7 @@ private void PlanVelocity(DtCrowdAgentDebugInfo debug, IList<DtCrowdAgent> agent
{
RcVec3f[] s = ag.boundary.GetSegment(j);
RcVec3f s3 = s[1];
//Array.Copy(s, 3, s3, 0, 3);
//RcArrays.Copy(s, 3, s3, 0, 3);
if (DtUtils.TriArea2D(ag.npos, s[0], s3) < 0.0f)
{
continue;
2 changes: 1 addition & 1 deletion src/DotRecast.Detour.Crowd/DtLocalBoundary.cs
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ protected void AddSegment(float dist, RcSegmentVert s)
DtSegment seg = new DtSegment();
seg.s[0] = s.vmin;
seg.s[1] = s.vmax;
//Array.Copy(s, seg.s, 6);
//RcArrays.Copy(s, seg.s, 6);
seg.d = dist;
if (0 == m_segs.Count)
{
4 changes: 2 additions & 2 deletions src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs
Original file line number Diff line number Diff line change
@@ -64,8 +64,8 @@ private List<JumpLink> BuildJumpLinks(JumpLinkBuilderConfig acfg, EdgeSampler es
{
JumpLink link = new JumpLink();
links.Add(link);
link.startSamples = RcArrayUtils.CopyOf(es.start.gsamples, js.startSample, js.samples);
link.endSamples = RcArrayUtils.CopyOf(end.gsamples, js.startSample, js.samples);
link.startSamples = RcArrays.CopyOf(es.start.gsamples, js.startSample, js.samples);
link.endSamples = RcArrays.CopyOf(end.gsamples, js.startSample, js.samples);
link.start = es.start;
link.end = end;
link.trajectory = es.trajectory;
2 changes: 1 addition & 1 deletion src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ class JumpSegmentBuilder
public JumpSegment[] Build(JumpLinkBuilderConfig acfg, EdgeSampler es)
{
int n = es.end[0].gsamples.Length;
int[][] sampleGrid = RcArrayUtils.Of<int>(n, es.end.Count);
int[][] sampleGrid = RcArrays.Of<int>(n, es.end.Count);
for (int j = 0; j < es.end.Count; j++)
{
for (int i = 0; i < n; i++)
6 changes: 3 additions & 3 deletions src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs
Original file line number Diff line number Diff line change
@@ -37,13 +37,13 @@ public void Build(GraphMeshData graphData, NodeLink2[] links, int nodeOffset)
if (startNode != null && endNode != null)
{
// FIXME: Optimise
startTile.polys = RcArrayUtils.CopyOf(startTile.polys, startTile.polys.Length + 1);
startTile.polys = RcArrays.CopyOf(startTile.polys, startTile.polys.Length + 1);
int poly = startTile.header.polyCount;
startTile.polys[poly] = new DtPoly(poly, 2);
startTile.polys[poly].verts[0] = startTile.header.vertCount;
startTile.polys[poly].verts[1] = startTile.header.vertCount + 1;
startTile.polys[poly].SetPolyType(DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION);
startTile.verts = RcArrayUtils.CopyOf(startTile.verts, startTile.verts.Length + 6);
startTile.verts = RcArrays.CopyOf(startTile.verts, startTile.verts.Length + 6);
startTile.header.polyCount++;
startTile.header.vertCount += 2;
DtOffMeshConnection connection = new DtOffMeshConnection();
@@ -63,7 +63,7 @@ public void Build(GraphMeshData graphData, NodeLink2[] links, int nodeOffset)
}
else
{
startTile.offMeshCons = RcArrayUtils.CopyOf(startTile.offMeshCons, startTile.offMeshCons.Length + 1);
startTile.offMeshCons = RcArrays.CopyOf(startTile.offMeshCons, startTile.offMeshCons.Length + 1);
}

startTile.offMeshCons[startTile.offMeshCons.Length - 1] = connection;
8 changes: 4 additions & 4 deletions src/DotRecast.Detour.TileCache/DtTileCacheBuilder.cs
Original file line number Diff line number Diff line change
@@ -1275,7 +1275,7 @@ private void MergePolys(int[] polys, int pa, int pb, int ea, int eb, int maxVert
// Add pb
for (int i = 0; i < nb - 1; ++i)
tmp[n++] = polys[pb + (eb + 1 + i) % nb];
Array.Copy(tmp, 0, polys, pa, maxVertsPerPoly);
RcArrays.Copy(tmp, 0, polys, pa, maxVertsPerPoly);
}

private int PushFront(int v, List<int> arr)
@@ -1434,7 +1434,7 @@ private void RemoveVertex(DtTileCachePolyMesh mesh, int rem, int maxTris)

// Remove the polygon.
int p2 = (mesh.npolys - 1) * maxVertsPerPoly * 2;
Array.Copy(mesh.polys, p2, mesh.polys, p, maxVertsPerPoly);
RcArrays.Copy(mesh.polys, p2, mesh.polys, p, maxVertsPerPoly);
Array.Fill(mesh.polys, DT_TILECACHE_NULL_IDX, p + maxVertsPerPoly, maxVertsPerPoly);
mesh.areas[i] = mesh.areas[mesh.npolys - 1];
mesh.npolys--;
@@ -1597,7 +1597,7 @@ private void RemoveVertex(DtTileCachePolyMesh mesh, int rem, int maxTris)
int pa = bestPa * maxVertsPerPoly;
int pb = bestPb * maxVertsPerPoly;
MergePolys(polys, pa, pb, bestEa, bestEb, maxVertsPerPoly);
Array.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly);
RcArrays.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly);
pareas[bestPb] = pareas[npolys - 1];
npolys--;
}
@@ -1753,7 +1753,7 @@ public DtTileCachePolyMesh BuildTileCachePolyMesh(DtTileCacheContourSet lcset, i
int pa = bestPa * maxVertsPerPoly;
int pb = bestPb * maxVertsPerPoly;
MergePolys(polys, pa, pb, bestEa, bestEb, maxVertsPerPoly);
Array.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly);
RcArrays.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly);
npolys--;
}
else
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ public byte[] Compress(byte[] buf)
{
byte[] output = new byte[FastLZ.EstimateCompressedSize(buf.Length)];
long len = FastLZ.CompressLevel(2, buf, 0, buf.Length, output);
return RcArrayUtils.CopyOf(output, len);
return RcArrays.CopyOf(output, len);
}
}
}
3 changes: 2 additions & 1 deletion src/DotRecast.Detour/DtConvexConvexIntersections.cs
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ 3. This notice may not be removed or altered from any source distribution.
*/

using System;
using DotRecast.Core;
using DotRecast.Core.Numerics;

namespace DotRecast.Detour
@@ -171,7 +172,7 @@ public static float[] Intersect(float[] p, float[] q)
}

float[] copied = new float[ii];
Array.Copy(inters, copied, ii);
RcArrays.Copy(inters, copied, ii);
return copied;
}

2 changes: 1 addition & 1 deletion src/DotRecast.Detour/DtNavMesh.cs
Original file line number Diff line number Diff line change
@@ -1251,7 +1251,7 @@ public bool GetPolyHeight(DtMeshTile tile, DtPoly poly, RcVec3f pos, out float h
int nv = poly.vertCount;
for (int i = 0; i < nv; ++i)
{
Array.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3);
RcArrays.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3);
}

if (!DtUtils.PointInPolygon(pos, verts, nv))
7 changes: 4 additions & 3 deletions src/DotRecast.Detour/DtNavMeshBuilder.cs
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ 3. This notice may not be removed or altered from any source distribution.
*/

using System;
using DotRecast.Core;
using DotRecast.Core.Numerics;

namespace DotRecast.Detour
@@ -468,7 +469,7 @@ public static DtMeshData CreateNavMeshData(DtNavMeshCreateParams option)
{
int linkv = i * 2 * 3;
int v = (offMeshVertsBase + n * 2) * 3;
Array.Copy(option.offMeshConVerts, linkv, navVerts, v, 6);
RcArrays.Copy(option.offMeshConVerts, linkv, navVerts, v, 6);
n++;
}
}
@@ -557,13 +558,13 @@ public static DtMeshData CreateNavMeshData(DtNavMeshCreateParams option)
// nav poly verts.
if (ndv - nv != 0)
{
Array.Copy(option.detailVerts, (vb + nv) * 3, navDVerts, vbase * 3, 3 * (ndv - nv));
RcArrays.Copy(option.detailVerts, (vb + nv) * 3, navDVerts, vbase * 3, 3 * (ndv - nv));
vbase += ndv - nv;
}
}

// Store triangles.
Array.Copy(option.detailTris, 0, navDTris, 0, 4 * option.detailTriCount);
RcArrays.Copy(option.detailTris, 0, navDTris, 0, 4 * option.detailTriCount);
}
else
{
18 changes: 9 additions & 9 deletions src/DotRecast.Detour/DtNavMeshQuery.cs
Original file line number Diff line number Diff line change
@@ -136,10 +136,10 @@ public DtStatus FindRandomPoint(IDtQueryFilter filter, IRcRand frand, out long r
// Randomly pick point on polygon.
float[] verts = new float[3 * m_nav.GetMaxVertsPerPoly()];
float[] areas = new float[m_nav.GetMaxVertsPerPoly()];
Array.Copy(tile.data.verts, poly.verts[0] * 3, verts, 0, 3);
RcArrays.Copy(tile.data.verts, poly.verts[0] * 3, verts, 0, 3);
for (int j = 1; j < poly.vertCount; ++j)
{
Array.Copy(tile.data.verts, poly.verts[j] * 3, verts, j * 3, 3);
RcArrays.Copy(tile.data.verts, poly.verts[j] * 3, verts, j * 3, 3);
}

float s = frand.Next();
@@ -256,7 +256,7 @@ public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, fl
float[] polyVerts = new float[bestPoly.vertCount * 3];
for (int j = 0; j < bestPoly.vertCount; ++j)
{
Array.Copy(bestTile.data.verts, bestPoly.verts[j] * 3, polyVerts, j * 3, 3);
RcArrays.Copy(bestTile.data.verts, bestPoly.verts[j] * 3, polyVerts, j * 3, 3);
}

float[] constrainedVerts = constraint.Apply(polyVerts, centerPos, maxRadius);
@@ -453,7 +453,7 @@ public DtStatus ClosestPointOnPolyBoundary(long refs, RcVec3f pos, out RcVec3f c
int nv = poly.vertCount;
for (int i = 0; i < nv; ++i)
{
Array.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3);
RcArrays.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3);
}

if (DtUtils.DistancePtPolyEdgesSqr(pos, verts, nv, edged, edget))
@@ -1822,7 +1822,7 @@ public DtStatus MoveAlongSurface(long startRef, RcVec3f startPos, RcVec3f endPos
int nverts = curPoly.vertCount;
for (int i = 0; i < nverts; ++i)
{
Array.Copy(curTile.data.verts, curPoly.verts[i] * 3, verts, i * 3, 3);
RcArrays.Copy(curTile.data.verts, curPoly.verts[i] * 3, verts, i * 3, 3);
}

// If target is inside the poly, stop search.
@@ -2873,7 +2873,7 @@ public DtStatus FindLocalNeighbourhood(long startRef, RcVec3f centerPos, float r
int npa = neighbourPoly.vertCount;
for (int k = 0; k < npa; ++k)
{
Array.Copy(neighbourTile.data.verts, neighbourPoly.verts[k] * 3, pa, k * 3, 3);
RcArrays.Copy(neighbourTile.data.verts, neighbourPoly.verts[k] * 3, pa, k * 3, 3);
}

bool overlap = false;
@@ -2904,7 +2904,7 @@ public DtStatus FindLocalNeighbourhood(long startRef, RcVec3f centerPos, float r
int npb = pastPoly.vertCount;
for (int k = 0; k < npb; ++k)
{
Array.Copy(pastTile.data.verts, pastPoly.verts[k] * 3, pb, k * 3, 3);
RcArrays.Copy(pastTile.data.verts, pastPoly.verts[k] * 3, pb, k * 3, 3);
}

if (DtUtils.OverlapPolyPoly2D(pa, npa, pb, npb))
@@ -3033,8 +3033,8 @@ public DtStatus GetPolyWallSegments(long refs, bool storePortals, IDtQueryFilter
var seg = new RcSegmentVert();
seg.vmin = RcVecUtils.Create(tile.data.verts, ivj);
seg.vmax = RcVecUtils.Create(tile.data.verts, ivi);
// Array.Copy(tile.data.verts, ivj, seg, 0, 3);
// Array.Copy(tile.data.verts, ivi, seg, 3, 3);
// RcArrays.Copy(tile.data.verts, ivj, seg, 0, 3);
// RcArrays.Copy(tile.data.verts, ivi, seg, 3, 3);
segmentVerts.Add(seg);
segmentRefs.Add(neiRef);
continue;
3 changes: 2 additions & 1 deletion src/DotRecast.Recast.Demo/Draw/ArrayBuffer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using DotRecast.Core;

namespace DotRecast.Recast.Demo.Draw;

@@ -24,7 +25,7 @@ public void Add(T item)
if (_items.Length <= _size)
{
var temp = new T[(int)(_size * 1.5)];
Array.Copy(_items, 0, temp, 0, _items.Length);
RcArrays.Copy(_items, 0, temp, 0, _items.Length);
_items = temp;
}

2 changes: 1 addition & 1 deletion src/DotRecast.Recast.Demo/Draw/GLU.cs
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ static void MultiplyMatrixByVector4by4OpenGL_FLOAT(float[] resultvector, float[]
// This code comes directly from GLU except that it is for float
static int GlhInvertMatrixf2(float[] m, float[] @out)
{
float[][] wtmp = RcArrayUtils.Of<float>(4, 8);
float[][] wtmp = RcArrays.Of<float>(4, 8);
float m0, m1, m2, m3, s;
float[] r0, r1, r2, r3;
r0 = wtmp[0];
2 changes: 1 addition & 1 deletion src/DotRecast.Recast.Demo/DtVoxelTileLZ4DemoCompressor.cs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ public byte[] Compress(byte[] data)
byte[] compressed = LZ4Pickler.Pickle(data, LZ4Level.L12_MAX);
byte[] result = new byte[4 + compressed.Length];
RcByteUtils.PutInt(compressed.Length, result, 0, RcByteOrder.BIG_ENDIAN);
Array.Copy(compressed, 0, result, 4, compressed.Length);
RcArrays.Copy(compressed, 0, result, 4, compressed.Length);
return result;
}
}
2 changes: 1 addition & 1 deletion src/DotRecast.Recast.Toolset/Tools/RcConvexVolumeTool.cs
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ public static RcConvexVolume CreateConvexVolume(List<RcVec3f> pts, List<int> hul
int noffset = RcAreas.OffsetPoly(verts, hull.Count, polyOffset, offset, offset.Length);
if (noffset > 0)
{
verts = RcArrayUtils.CopyOf(offset, 0, noffset * 3);
verts = RcArrays.CopyOf(offset, 0, noffset * 3);
}
}

6 changes: 3 additions & 3 deletions src/DotRecast.Recast/RcFilledVolumeRasterization.cs
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ public static void RasterizeBox(RcHeightfield hf, RcVec3f center, RcVec3f[] half
bounds[5] = Math.Max(bounds[5], vertices[i * 3 + 2]);
}

float[][] planes = RcArrayUtils.Of<float>(6, 4);
float[][] planes = RcArrays.Of<float>(6, 4);
for (int i = 0; i < 6; i++)
{
float m = i < 3 ? -1 : 1;
@@ -135,8 +135,8 @@ public static void RasterizeConvex(RcHeightfield hf, float[] vertices, int[] tri
}


float[][] planes = RcArrayUtils.Of<float>(triangles.Length, 4);
float[][] triBounds = RcArrayUtils.Of<float>(triangles.Length / 3, 4);
float[][] planes = RcArrays.Of<float>(triangles.Length, 4);
float[][] triBounds = RcArrays.Of<float>(triangles.Length / 3, 4);
for (int i = 0, j = 0; i < triangles.Length; i += 3, j++)
{
int a = triangles[i] * 3;
4 changes: 2 additions & 2 deletions src/DotRecast.Recast/RcMeshDetails.cs
Original file line number Diff line number Diff line change
@@ -1562,7 +1562,7 @@ public static RcPolyMeshDetail BuildPolyMeshDetail(RcTelemetry ctx, RcPolyMesh m
float[] newv = new float[vcap * 3];
if (dmesh.nverts != 0)
{
Array.Copy(dmesh.verts, 0, newv, 0, 3 * dmesh.nverts);
RcArrays.Copy(dmesh.verts, 0, newv, 0, 3 * dmesh.nverts);
}

dmesh.verts = newv;
@@ -1587,7 +1587,7 @@ public static RcPolyMeshDetail BuildPolyMeshDetail(RcTelemetry ctx, RcPolyMesh m
int[] newt = new int[tcap * 4];
if (dmesh.ntris != 0)
{
Array.Copy(dmesh.tris, 0, newt, 0, 4 * dmesh.ntris);
RcArrays.Copy(dmesh.tris, 0, newt, 0, 4 * dmesh.ntris);
}

dmesh.tris = newt;
18 changes: 9 additions & 9 deletions src/DotRecast.Recast/RcMeshs.cs
Original file line number Diff line number Diff line change
@@ -558,7 +558,7 @@ private static void MergePolyVerts(int[] polys, int pa, int pb, int ea, int eb,
n++;
}

Array.Copy(polys, tmp, polys, pa, nvp);
RcArrays.Copy(polys, tmp, polys, pa, nvp);
}

private static int PushFront(int v, int[] arr, int an)
@@ -737,7 +737,7 @@ private static void RemoveVertex(RcTelemetry ctx, RcPolyMesh mesh, int rem, int
int p2 = (mesh.npolys - 1) * nvp * 2;
if (p != p2)
{
Array.Copy(mesh.polys, p2, mesh.polys, p, nvp);
RcArrays.Copy(mesh.polys, p2, mesh.polys, p, nvp);
}

Array.Fill(mesh.polys, RC_MESH_NULL_IDX, p + nvp, (p + nvp + nvp) - (p + nvp));
@@ -927,7 +927,7 @@ private static void RemoveVertex(RcTelemetry ctx, RcPolyMesh mesh, int rem, int
int last = (npolys - 1) * nvp;
if (pb != last)
{
Array.Copy(polys, last, polys, pb, nvp);
RcArrays.Copy(polys, last, polys, pb, nvp);
}

pregs[bestPb] = pregs[npolys - 1];
@@ -1109,7 +1109,7 @@ public static RcPolyMesh BuildPolyMesh(RcTelemetry ctx, RcContourSet cset, int n
int lastPoly = (npolys - 1) * nvp;
if (pb != lastPoly)
{
Array.Copy(polys, lastPoly, polys, pb, nvp);
RcArrays.Copy(polys, lastPoly, polys, pb, nvp);
}

npolys--;
@@ -1356,15 +1356,15 @@ public static RcPolyMesh CopyPolyMesh(RcTelemetry ctx, RcPolyMesh src)
dst.maxEdgeError = src.maxEdgeError;

dst.verts = new int[src.nverts * 3];
Array.Copy(src.verts, 0, dst.verts, 0, dst.verts.Length);
RcArrays.Copy(src.verts, 0, dst.verts, 0, dst.verts.Length);
dst.polys = new int[src.npolys * 2 * src.nvp];
Array.Copy(src.polys, 0, dst.polys, 0, dst.polys.Length);
RcArrays.Copy(src.polys, 0, dst.polys, 0, dst.polys.Length);
dst.regs = new int[src.npolys];
Array.Copy(src.regs, 0, dst.regs, 0, dst.regs.Length);
RcArrays.Copy(src.regs, 0, dst.regs, 0, dst.regs.Length);
dst.areas = new int[src.npolys];
Array.Copy(src.areas, 0, dst.areas, 0, dst.areas.Length);
RcArrays.Copy(src.areas, 0, dst.areas, 0, dst.areas.Length);
dst.flags = new int[src.npolys];
Array.Copy(src.flags, 0, dst.flags, 0, dst.flags.Length);
RcArrays.Copy(src.flags, 0, dst.flags, 0, dst.flags.Length);
return dst;
}
}
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ public byte[] Compress(byte[] data)
byte[] compressed = LZ4Pickler.Pickle(data, LZ4Level.L12_MAX);
byte[] result = new byte[4 + compressed.Length];
RcByteUtils.PutInt(compressed.Length, result, 0, RcByteOrder.BIG_ENDIAN);
Array.Copy(compressed, 0, result, 4, compressed.Length);
RcArrays.Copy(compressed, 0, result, 4, compressed.Length);
return result;
}
}

0 comments on commit 69c8c95

Please sign in to comment.