Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Renaming Fast*ArrayEqual to FastArrayEqual, adding more overloads.
  • Loading branch information
MainMemory committed May 14, 2015
1 parent e26c6ee commit df53afe
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 95 deletions.
2 changes: 1 addition & 1 deletion LevelConverter/MainForm.cs
Expand Up @@ -492,7 +492,7 @@ private void ConvertLevel()
byte[] b = newchnk[i].GetBytes();
int match = -1;
for (int c = 0; c < tmpchnk.Count; c++)
if (b.FastByteArrayEqual(tmpchnk[c].GetBytes()))
if (b.FastArrayEqual(tmpchnk[c].GetBytes()))
{
match = c;
break;
Expand Down
2 changes: 1 addition & 1 deletion ObjectLayoutDiff/Program.cs
Expand Up @@ -37,7 +37,7 @@ static void Main(string[] args)
List<ObjectEntry> newobjs = LoadObjects(File.ReadAllBytes(args[3]), format);
for (int i = 0; i < origobjs.Count; i++)
for (int j = 0; j < newobjs.Count; j++)
if (origobjs[i].GetBytes().FastByteArrayEqual(newobjs[j].GetBytes()))
if (origobjs[i].GetBytes().FastArrayEqual(newobjs[j].GetBytes()))
{
origobjs.RemoveAt(i--);
newobjs.RemoveAt(j);
Expand Down
52 changes: 26 additions & 26 deletions SonLVL/MainForm.cs
Expand Up @@ -4315,7 +4315,7 @@ private void pasteBeforeToolStripMenuItem_Click(object sender, EventArgs e)
{
ushort ti = (ushort)LevelData.Tiles.Count;
for (ushort j = 0; j < LevelData.Tiles.Count; j++)
if (tile.FastByteArrayEqual(LevelData.Tiles[j]))
if (tile.FastArrayEqual(LevelData.Tiles[j]))
{
ti = j;
break;
Expand Down Expand Up @@ -4381,7 +4381,7 @@ private void pasteBeforeToolStripMenuItem_Click(object sender, EventArgs e)
{
ushort ti = (ushort)LevelData.Tiles.Count;
for (ushort j = 0; j < LevelData.Tiles.Count; j++)
if (tile.FastByteArrayEqual(LevelData.Tiles[j]))
if (tile.FastArrayEqual(LevelData.Tiles[j]))
{
ti = j;
break;
Expand Down Expand Up @@ -4450,7 +4450,7 @@ private void pasteAfterToolStripMenuItem_Click(object sender, EventArgs e)
{
ushort ti = (ushort)LevelData.Tiles.Count;
for (ushort j = 0; j < LevelData.Tiles.Count; j++)
if (tile.FastByteArrayEqual(LevelData.Tiles[j]))
if (tile.FastArrayEqual(LevelData.Tiles[j]))
{
ti = j;
break;
Expand Down Expand Up @@ -4517,7 +4517,7 @@ private void pasteAfterToolStripMenuItem_Click(object sender, EventArgs e)
{
ushort ti = (ushort)LevelData.Tiles.Count;
for (ushort j = 0; j < LevelData.Tiles.Count; j++)
if (tile.FastByteArrayEqual(LevelData.Tiles[j]))
if (tile.FastArrayEqual(LevelData.Tiles[j]))
{
ti = j;
break;
Expand Down Expand Up @@ -4788,27 +4788,27 @@ private void ImportImage(Bitmap bmp, Bitmap colbmp1, Bitmap colbmp2, Bitmap prib
if (!Object.ReferenceEquals(LevelData.ColInds1, LevelData.ColInds2) && colInds2[i] != col.ColInd2)
continue;
}
if (blkb.FastByteArrayEqual(blocks[i]))
if (blkb.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
break;
}
if (blkh.FastByteArrayEqual(blocks[i]))
if (blkh.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
cnk.Blocks[bx, by].XFlip = true;
break;
}
if (blkv.FastByteArrayEqual(blocks[i]))
if (blkv.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
cnk.Blocks[bx, by].YFlip = true;
break;
}
if (blkhv.FastByteArrayEqual(blocks[i]))
if (blkhv.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
Expand All @@ -4831,7 +4831,7 @@ private void ImportImage(Bitmap bmp, Bitmap colbmp1, Bitmap colbmp2, Bitmap prib
for (int i = 0; i < chunks.Count; i++)
{
Application.DoEvents();
if (cnkb.FastByteArrayEqual(chunks[i]))
if (cnkb.FastArrayEqual(chunks[i]))
{
match = true;
break;
Expand Down Expand Up @@ -5001,8 +5001,8 @@ private void ImportImage(Bitmap bmp, Bitmap colbmp1, Bitmap colbmp2, Bitmap prib
if (!Object.ReferenceEquals(LevelData.ColInds1, LevelData.ColInds2) && LevelData.ColInds2[i] != col.ColInd2)
continue;
}
if (blkb.FastByteArrayEqual(blocks[i]) || blkh.FastByteArrayEqual(blocks[i])
|| blkv.FastByteArrayEqual(blocks[i]) || blkhv.FastByteArrayEqual(blocks[i]))
if (blkb.FastArrayEqual(blocks[i]) || blkh.FastArrayEqual(blocks[i])
|| blkv.FastArrayEqual(blocks[i]) || blkhv.FastArrayEqual(blocks[i]))
{
match = true;
break;
Expand Down Expand Up @@ -7699,7 +7699,7 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)
{
ushort ti = (ushort)LevelData.Tiles.Count;
for (ushort j = 0; j < LevelData.Tiles.Count; j++)
if (tile.FastByteArrayEqual(LevelData.Tiles[j]))
if (tile.FastArrayEqual(LevelData.Tiles[j]))
{
ti = j;
break;
Expand Down Expand Up @@ -7763,7 +7763,7 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)
{
ushort ti = (ushort)LevelData.Tiles.Count;
for (ushort j = 0; j < LevelData.Tiles.Count; j++)
if (tile.FastByteArrayEqual(LevelData.Tiles[j]))
if (tile.FastArrayEqual(LevelData.Tiles[j]))
{
ti = j;
break;
Expand Down Expand Up @@ -7956,27 +7956,27 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)
if (!Object.ReferenceEquals(LevelData.ColInds1, LevelData.ColInds2) && colInds2[i] != col.ColInd2)
continue;
}
if (blkb.FastByteArrayEqual(blocks[i]))
if (blkb.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
break;
}
if (blkh.FastByteArrayEqual(blocks[i]))
if (blkh.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
cnk.Blocks[bx, by].XFlip = true;
break;
}
if (blkv.FastByteArrayEqual(blocks[i]))
if (blkv.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
cnk.Blocks[bx, by].YFlip = true;
break;
}
if (blkhv.FastByteArrayEqual(blocks[i]))
if (blkhv.FastArrayEqual(blocks[i]))
{
match = true;
cnk.Blocks[bx, by].Block = (ushort)i;
Expand All @@ -7999,7 +7999,7 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)
for (int i = 0; i < chunks.Count; i++)
{
Application.DoEvents();
if (cnkb.FastByteArrayEqual(chunks[i]))
if (cnkb.FastArrayEqual(chunks[i]))
{
result[cx, cy] = (byte)i;
match = true;
Expand Down Expand Up @@ -8116,7 +8116,7 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)
blk2 = coldata2[x, y];
byte ind1 = 0, ind2 = 0;
bool xflip = false, yflip = false;
if ((blk1.HeightMap.FastSByteArrayEqual(LevelData.ColArr1[0xFF]) || blk1.Solidity == Solidity.NotSolid) && coldata2 != null)
if ((blk1.HeightMap.FastArrayEqual(LevelData.ColArr1[0xFF]) || blk1.Solidity == Solidity.NotSolid) && coldata2 != null)
{
ind1 = (byte)(blk1.Solidity == Solidity.NotSolid ? 0 : 0xFF);
if (blk2.Solidity != Solidity.NotSolid)
Expand All @@ -8128,7 +8128,7 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)
MatchCol(blk1, out ind1, out xflip, out yflip);
if (blk2.Solidity != Solidity.NotSolid)
{
if (blk2.HeightMap.FastSByteArrayEqual(LevelData.ColArr1[0xFF]))
if (blk2.HeightMap.FastArrayEqual(LevelData.ColArr1[0xFF]))
{
ind2 = 0xFF;
}
Expand All @@ -8153,7 +8153,7 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)
bool found = false;
for (int i = 0; i < LevelData.ColArr1.Length; i++)
{
if (map.FastSByteArrayEqual(LevelData.ColArr1[i]))
if (map.FastArrayEqual(LevelData.ColArr1[i]))
{
ind2 = (byte)i;
found = true;
Expand Down Expand Up @@ -8181,7 +8181,7 @@ private void pasteOverToolStripMenuItem_Click(object sender, EventArgs e)

private void MatchCol(ColInfo blk, out byte ind, out bool xflip, out bool yflip)
{
if (blk.HeightMap.FastSByteArrayEqual(LevelData.ColArr1[0xFF]))
if (blk.HeightMap.FastArrayEqual(LevelData.ColArr1[0xFF]))
{
xflip = false;
yflip = false;
Expand All @@ -8198,28 +8198,28 @@ private void MatchCol(ColInfo blk, out byte ind, out bool xflip, out bool yflip)
byte? emptymap = null;
for (int i = 0; i < LevelData.ColArr1.Length; i++)
{
if (blk.HeightMap.FastSByteArrayEqual(LevelData.ColArr1[i]))
if (blk.HeightMap.FastArrayEqual(LevelData.ColArr1[i]))
{
xflip = false;
yflip = false;
ind = (byte)i;
return;
}
if (maph.FastSByteArrayEqual(LevelData.ColArr1[i]))
if (maph.FastArrayEqual(LevelData.ColArr1[i]))
{
xflip = true;
yflip = false;
ind = (byte)i;
return;
}
if (mapv.FastSByteArrayEqual(LevelData.ColArr1[i]))
if (mapv.FastArrayEqual(LevelData.ColArr1[i]))
{
xflip = false;
yflip = true;
ind = (byte)i;
return;
}
if (maphv.FastSByteArrayEqual(LevelData.ColArr1[i]))
if (maphv.FastArrayEqual(LevelData.ColArr1[i]))
{
xflip = true;
yflip = true;
Expand Down
2 changes: 1 addition & 1 deletion SonLVLAPI/BitmapBits.cs
Expand Up @@ -558,7 +558,7 @@ public override bool Equals(object obj)
BitmapBits other = obj as BitmapBits;
if (other == null) return false;
if (Width != other.Width | Height != other.Height) return false;
return Bits.FastByteArrayEqual(other.Bits);
return Bits.FastArrayEqual(other.Bits);
}

public override int GetHashCode()
Expand Down

0 comments on commit df53afe

Please sign in to comment.