Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tsolomko committed Nov 5, 2016
2 parents b98645c + d58ed7a commit 74a8c9f
Show file tree
Hide file tree
Showing 16 changed files with 220 additions and 215 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

25 changes: 21 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
branches:
- develop
- master

osx_image: xcode8
- develop
- master
language: objective-c
osx_image: xcode8
xcode_project: SWCompression.xcodeproj
xcode_scheme: SWCompression
env:
global:
- FRAMEWORK_NAME=SWCompression
before_install:
- brew update
- brew outdated carthage || brew upgrade carthage
before_deploy:
- carthage build --no-skip-current
- carthage archive $FRAMEWORK_NAME
script:
- xcodebuild clean build test -project SWCompression.xcodeproj -scheme SWCompression
notifications:
email: false
deploy:
provider: releases
api_key:
secure: lhJi7BsAuhGo9T4rgD/UWlVRnfrO5xLIF3BUuPHb21045tEXk/BGEHgc9a9CTFm2/iR3SmP/GDsmqfJlMzWLvuTlyV5i8otIodwIp5NYstFhyA2JaEVglmnzlkf/2FkNb5KKJDyGM1KuecYmPRTUUzYThVXl59GZ2esgfiCN26pDeDgwRyJt34jeUj0VzK9JDmEJ/ODG/hvuUWyZp0zni+m6WTPZ7dILeazFEc81WATBfMo5oa8ZBChSM6lDKaW8XyKZWrMXjsK6dKfQTcVwnvrplfw2TqfPVA+YfePcq1os5Do5CELnhrUZMSI6qvOmPauzGStjsAVFTiMaYO6HdHO03mn5L9SUuyhhKqHmh2pAkM1zKxbtfKbk6oi4zJJgvbTjIO4K2X5SUwHFgjULijW9JJeCFjsLfwODvFNFHeLeql3jaKNo6kRn2VvT/uNuT3aZa+r+WeFL0HgD6Z/EEkQW5yI6DocjetRP6y9B0rpA+YyALbd0SkVIqvoywztSfxWwp7eKhQHbG/FTIfWlmMbtLq5xULQb6TyjVHO94iSfsDV2rjAeDJY73P+rPsvej4Y9LFS8VOHcsrFhFlbR9E0NjCO2CH2TZcjXPOdLu4gfapPdiqQIdgWjC6ECUwsq+Ux6jJ6QIrGC2TI/Fw58mtLf1G8SdqBRXo+Kw0IAB4g=
file: "$FRAMEWORK_NAME.framework.zip"
skip_cleanup: true
on:
repo: tsolomko/SWCompression
tags: true
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Changelog

v1.0.3
----------------
Great performance improvements (but there is still room for more improvements).

v1.0.2
----------------
- Fixed a problem when decompressed amount of data was greater than expected.
- Performance improvement.

v1.0.1
----------------
Fixed several crashes caused by mistyping and shift 'overflow' (when it becomes greater than 15).
Fixed several crashes caused by mistyping and shift 'overflow' (when it becomes greater than 15).

v1.0.0
----------------
Expand Down
2 changes: 1 addition & 1 deletion SWCompression.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SWCompression"
s.version = "1.0.2"
s.version = "1.0.3"
s.summary = "Framework with implementations in Swift of different (de)compression algorithms"

s.description = <<-DESC
Expand Down
20 changes: 19 additions & 1 deletion SWCompression.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
0655697F1DC6966300A47E66 /* secondtest.zlib.answer in Resources */ = {isa = PBXBuildFile; fileRef = 0655697E1DC6966300A47E66 /* secondtest.zlib.answer */; };
065569811DC69DD500A47E66 /* thirdtest.zlib.answer in Resources */ = {isa = PBXBuildFile; fileRef = 065569801DC69DD500A47E66 /* thirdtest.zlib.answer */; };
065569831DC69DDE00A47E66 /* thirdtest.zlib in Resources */ = {isa = PBXBuildFile; fileRef = 065569821DC69DDE00A47E66 /* thirdtest.zlib */; };
0661F06F1DC92391006C3D35 /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0661F06E1DC92391006C3D35 /* PerformanceTests.swift */; };
0661F0711DC92590006C3D35 /* relatively_big_file.gz in Resources */ = {isa = PBXBuildFile; fileRef = 0661F0701DC92590006C3D35 /* relatively_big_file.gz */; };
0661F0731DC92F98006C3D35 /* DataWithPointer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0661F0721DC92F98006C3D35 /* DataWithPointer.swift */; };
0661F0741DC92F98006C3D35 /* DataWithPointer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0661F0721DC92F98006C3D35 /* DataWithPointer.swift */; };
0661F0751DC92F98006C3D35 /* DataWithPointer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0661F0721DC92F98006C3D35 /* DataWithPointer.swift */; };
0661F0761DC92F98006C3D35 /* DataWithPointer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0661F0721DC92F98006C3D35 /* DataWithPointer.swift */; };
06AC9B0D1DC1027900A5066B /* HuffmanLength.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06AC9B0C1DC1027900A5066B /* HuffmanLength.swift */; };
06BE1AD21DB410F100EE0F59 /* SWCompression.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06BE1AC81DB410F100EE0F59 /* SWCompression.framework */; };
06BE1AD71DB410F100EE0F59 /* SWCompressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06BE1AD61DB410F100EE0F59 /* SWCompressionTests.swift */; };
Expand Down Expand Up @@ -87,6 +93,9 @@
0655697E1DC6966300A47E66 /* secondtest.zlib.answer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = secondtest.zlib.answer; sourceTree = "<group>"; };
065569801DC69DD500A47E66 /* thirdtest.zlib.answer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = thirdtest.zlib.answer; sourceTree = "<group>"; };
065569821DC69DDE00A47E66 /* thirdtest.zlib */ = {isa = PBXFileReference; lastKnownFileType = file; path = thirdtest.zlib; sourceTree = "<group>"; };
0661F06E1DC92391006C3D35 /* PerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceTests.swift; sourceTree = "<group>"; };
0661F0701DC92590006C3D35 /* relatively_big_file.gz */ = {isa = PBXFileReference; lastKnownFileType = archive.gzip; path = relatively_big_file.gz; sourceTree = "<group>"; };
0661F0721DC92F98006C3D35 /* DataWithPointer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataWithPointer.swift; sourceTree = "<group>"; };
06AC9B0C1DC1027900A5066B /* HuffmanLength.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HuffmanLength.swift; sourceTree = "<group>"; };
06BE1AC81DB410F100EE0F59 /* SWCompression.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SWCompression.framework; sourceTree = BUILT_PRODUCTS_DIR; };
06BE1ACB1DB410F100EE0F59 /* SWCompression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SWCompression.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -142,6 +151,7 @@
061FCE271DBCC6070052F7BE /* Test Files */ = {
isa = PBXGroup;
children = (
0661F0701DC92590006C3D35 /* relatively_big_file.gz */,
063364DC1DC51D33007E313F /* empty.txt */,
063364DD1DC51D33007E313F /* empty.txt.gz */,
061FCE281DBCC6070052F7BE /* helloworld.txt */,
Expand Down Expand Up @@ -185,9 +195,10 @@
063364E21DC52979007E313F /* GzipArchive.swift */,
064492581DC606D400F10981 /* ZlibArchive.swift */,
061FCE251DBCC4BE0052F7BE /* Deflate.swift */,
0661F0721DC92F98006C3D35 /* DataWithPointer.swift */,
061FCE301DBCC8BF0052F7BE /* Extensions.swift */,
06E961C91DBD5FA1008C47F2 /* HuffmanTable.swift */,
06AC9B0C1DC1027900A5066B /* HuffmanLength.swift */,
061FCE301DBCC8BF0052F7BE /* Extensions.swift */,
06BE1ACC1DB410F100EE0F59 /* Info.plist */,
065569611DC65B1B00A47E66 /* Info-iOS.plist */,
065569621DC65B1B00A47E66 /* Info-tvOS.plist */,
Expand All @@ -202,6 +213,7 @@
children = (
061FCE271DBCC6070052F7BE /* Test Files */,
06BE1AD61DB410F100EE0F59 /* SWCompressionTests.swift */,
0661F06E1DC92391006C3D35 /* PerformanceTests.swift */,
061FCE2C1DBCC6A30052F7BE /* Constants.swift */,
06BE1AD81DB410F100EE0F59 /* Info.plist */,
);
Expand Down Expand Up @@ -438,6 +450,7 @@
065569811DC69DD500A47E66 /* thirdtest.zlib.answer in Resources */,
061FCE2A1DBCC6070052F7BE /* helloworld.txt in Resources */,
065569831DC69DDE00A47E66 /* thirdtest.zlib in Resources */,
0661F0711DC92590006C3D35 /* relatively_big_file.gz in Resources */,
063364DE1DC51D33007E313F /* empty.txt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -456,6 +469,7 @@
065569681DC65C2A00A47E66 /* GzipArchive.swift in Sources */,
065569671DC65C2A00A47E66 /* Protocols.swift in Sources */,
0655696D1DC65C2A00A47E66 /* Extensions.swift in Sources */,
0661F0741DC92F98006C3D35 /* DataWithPointer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -470,6 +484,7 @@
0655696F1DC65C2B00A47E66 /* GzipArchive.swift in Sources */,
0655696E1DC65C2B00A47E66 /* Protocols.swift in Sources */,
065569741DC65C2B00A47E66 /* Extensions.swift in Sources */,
0661F0751DC92F98006C3D35 /* DataWithPointer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -484,6 +499,7 @@
065569761DC65C2B00A47E66 /* GzipArchive.swift in Sources */,
065569751DC65C2B00A47E66 /* Protocols.swift in Sources */,
0655697B1DC65C2B00A47E66 /* Extensions.swift in Sources */,
0661F0761DC92F98006C3D35 /* DataWithPointer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -498,6 +514,7 @@
061FCE261DBCC4BE0052F7BE /* Deflate.swift in Sources */,
063364E31DC52979007E313F /* GzipArchive.swift in Sources */,
061FCE311DBCC8BF0052F7BE /* Extensions.swift in Sources */,
0661F0731DC92F98006C3D35 /* DataWithPointer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -507,6 +524,7 @@
files = (
06BE1AD71DB410F100EE0F59 /* SWCompressionTests.swift in Sources */,
061FCE2D1DBCC6A30052F7BE /* Constants.swift in Sources */,
0661F06F1DC92391006C3D35 /* PerformanceTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
79 changes: 79 additions & 0 deletions Sources/DataWithPointer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// DataWithPointer.swift
// SWCompression
//
// Created by Timofey Solomko on 01.11.16.
// Copyright © 2016 Timofey Solomko. All rights reserved.
//

import Foundation
import CoreFoundation

class DataWithPointer {

/// Only needed for creation of bitVector in initData()
let data: Data

private(set) var bitVector: CFBitVector?
private(set) var index: Int
private(set) var bitShift: Int

init(data: Data) {
self.data = data
self.index = 0
self.bitShift = 0
self.bitVector = nil
data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) in
self.bitVector = CFBitVectorCreate(kCFAllocatorDefault, bytes, data.count * 8)
}
}

func bits(count: Int) -> [UInt8] {
guard count > 0 else { return [] }

var array: [UInt8] = []
for _ in 0..<count {
let currentIndex = 8 * (index + 1) - bitShift - 1
array.append(UInt8(truncatingBitPattern: CFBitVectorGetBitAtIndex(self.bitVector!, currentIndex)))
self.bitShift += 1
if self.bitShift >= 8 {
self.bitShift = 0
self.index += 1
}
}

return array
}

func bit() -> UInt8 {
return self.bits(count: 1).first!
}

/// Use with caution: not effective.
func data(ofBytes count: Data.Index) -> Data {
precondition(self.bitShift == 0, "Misaligned byte.")
let returnData = Data(data[index..<index+count])
index += count
return returnData
}

// MARK: Manipulation with index and bitShift

func skipUntilNextByte() {
self.index += 1
self.bitShift = 0
}

func rewind(bitsCount: Int) {
let amountOfBytes = (bitsCount - self.bitShift) / 8 + 1
self.index -= amountOfBytes
self.bitShift = 8 - (bitsCount - self.bitShift) % 8

if self.bitShift == 8 {
self.index += 1
self.bitShift = 0
}
}


}
Loading

0 comments on commit 74a8c9f

Please sign in to comment.