Browse Source

Remove not needed DeepClone

pull/1846/head
Brian Popow 5 years ago
parent
commit
92ac52221c
  1. 4
      src/ImageSharp/Formats/Webp/Lossless/HuffmanTree.cs
  2. 6
      src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs

4
src/ImageSharp/Formats/Webp/Lossless/HuffmanTree.cs

@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
/// Represents the Huffman tree. /// Represents the Huffman tree.
/// </summary> /// </summary>
[DebuggerDisplay("TotalCount = {TotalCount}, Value = {Value}, Left = {PoolIndexLeft}, Right = {PoolIndexRight}")] [DebuggerDisplay("TotalCount = {TotalCount}, Value = {Value}, Left = {PoolIndexLeft}, Right = {PoolIndexRight}")]
internal struct HuffmanTree : IDeepCloneable internal struct HuffmanTree
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="HuffmanTree"/> struct. /// Initializes a new instance of the <see cref="HuffmanTree"/> struct.
@ -57,7 +57,5 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
return t1.Value < t2.Value ? -1 : 1; return t1.Value < t2.Value ? -1 : 1;
} }
public IDeepCloneable DeepClone() => new HuffmanTree(this);
} }
} }

6
src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs

@ -219,8 +219,8 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
while (treeSize > 1) while (treeSize > 1)
{ {
// Finish when we have only one root. // Finish when we have only one root.
treePool[treePoolSize++] = (HuffmanTree)tree[treeSize - 1].DeepClone(); treePool[treePoolSize++] = tree[treeSize - 1];
treePool[treePoolSize++] = (HuffmanTree)tree[treeSize - 2].DeepClone(); treePool[treePoolSize++] = tree[treeSize - 2];
int count = treePool[treePoolSize - 1].TotalCount + treePool[treePoolSize - 2].TotalCount; int count = treePool[treePoolSize - 1].TotalCount + treePool[treePoolSize - 2].TotalCount;
treeSize -= 2; treeSize -= 2;
@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
int startIdx = endIdx + num - 1; int startIdx = endIdx + num - 1;
for (int i = startIdx; i >= endIdx; i--) for (int i = startIdx; i >= endIdx; i--)
{ {
tree[i] = (HuffmanTree)tree[i - 1].DeepClone(); tree[i] = tree[i - 1];
} }
tree[k].TotalCount = count; tree[k].TotalCount = count;

Loading…
Cancel
Save