From c8a5813730bc9b17af75b047c69724c8d1874479 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sat, 24 Dec 2016 22:26:55 +0300 Subject: [PATCH] Removed append(contentsOf:) where possible and performed small cleanup. --- Sources/BZip2.swift | 9 +++++++-- Sources/Deflate.swift | 18 ++++++++++-------- Sources/HuffmanTree.swift | 5 +++-- Sources/ZlibArchive.swift | 5 ++--- Tests/GzipTests.swift | 6 ++++-- Tests/ZlibTests.swift | 6 ++++-- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/Sources/BZip2.swift b/Sources/BZip2.swift index a5825f2b..2d862447 100644 --- a/Sources/BZip2.swift +++ b/Sources/BZip2.swift @@ -80,6 +80,7 @@ public class BZip2: DecompressionAlgorithm { while true { let blockType: Int64 = Int64(pointerData.intFromBits(count: 48)) + // TODO: Add CRC check. // Next 32 bits are crc (which currently is not checked). let _ = pointerData.intFromBits(count: 32) @@ -114,7 +115,9 @@ public class BZip2: DecompressionAlgorithm { bitMask >>= 1 } } else { - used.append(contentsOf: Array(repeating: false, count: 16)) + for _ in 0..<16 { + used.append(false) + } } mapMask >>= 1 } @@ -209,7 +212,9 @@ public class BZip2: DecompressionAlgorithm { repeatPower <<= 1 continue } else if repeat_ > 0 { - buffer.append(contentsOf: Array(repeating: favourites[0], count: repeat_)) + for _ in 0.. 0 { - lengths.append(contentsOf: - (start..