aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpacien2018-11-30 18:44:20 +0100
committerpacien2018-11-30 18:44:20 +0100
commit5bbe75659aef55542268cbf35c66342cb22ce865 (patch)
tree53c1e79c4195be546ba5762d61eb995a4f9e0530 /src
parente88f60b63cb05f56a61060a953c726b7a78c0652 (diff)
downloadgziplike-5bbe75659aef55542268cbf35c66342cb22ce865.tar.gz
isolate lzss chain module
Diffstat (limited to 'src')
-rw-r--r--src/lzss/listpolyfill.nim (renamed from src/polyfill.nim)2
-rw-r--r--src/lzss/lzsschain.nim (renamed from src/lzsschain.nim)3
-rw-r--r--src/lzss/lzssencoder.nim (renamed from src/lzssencoder.nim)2
-rw-r--r--src/lzss/lzssnode.nim (renamed from src/lzssnode.nim)0
-rw-r--r--src/lzss/matchtable.nim (renamed from src/matchtable.nim)4
5 files changed, 6 insertions, 5 deletions
diff --git a/src/polyfill.nim b/src/lzss/listpolyfill.nim
index b252953..00b30ee 100644
--- a/src/polyfill.nim
+++ b/src/lzss/listpolyfill.nim
@@ -26,7 +26,7 @@ proc prepend*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]) =
26 26
27proc prepend*[T](L: var SinglyLinkedList[T], value: T) = 27proc prepend*[T](L: var SinglyLinkedList[T], value: T) =
28 ## prepends a node to `L`. Efficiency: O(1). 28 ## prepends a node to `L`. Efficiency: O(1).
29 polyfill.prepend(L, newSinglyLinkedNode(value)) 29 listpolyfill.prepend(L, newSinglyLinkedNode(value))
30 30
31proc append*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]) = 31proc append*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]) =
32 ## appends a node `n` to `L`. Efficiency: O(1). 32 ## appends a node `n` to `L`. Efficiency: O(1).
diff --git a/src/lzsschain.nim b/src/lzss/lzsschain.nim
index 44200f2..2ecff9e 100644
--- a/src/lzsschain.nim
+++ b/src/lzss/lzsschain.nim
@@ -15,7 +15,8 @@
15# along with this program. If not, see <https://www.gnu.org/licenses/>. 15# along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16
17import lists, tables, sugar 17import lists, tables, sugar
18import polyfill, integers, lzssnode, huffman/huffmantree 18import ../integers, ../huffman/huffmantree
19import listpolyfill, lzssnode
19 20
20const maxChainByteLength = 32_000 * wordBitLength 21const maxChainByteLength = 32_000 * wordBitLength
21 22
diff --git a/src/lzssencoder.nim b/src/lzss/lzssencoder.nim
index 05f3a16..8b750fb 100644
--- a/src/lzssencoder.nim
+++ b/src/lzss/lzssencoder.nim
@@ -15,7 +15,7 @@
15# along with this program. If not, see <https://www.gnu.org/licenses/>. 15# along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16
17import lists 17import lists
18import polyfill, matchtable, lzssnode, lzsschain 18import listpolyfill, matchtable, lzssnode, lzsschain
19 19
20const matchGroupLength = 3 20const matchGroupLength = 3
21const maxRefByteLength = high(uint8).int + matchGroupLength 21const maxRefByteLength = high(uint8).int + matchGroupLength
diff --git a/src/lzssnode.nim b/src/lzss/lzssnode.nim
index de5958d..de5958d 100644
--- a/src/lzssnode.nim
+++ b/src/lzss/lzssnode.nim
diff --git a/src/matchtable.nim b/src/lzss/matchtable.nim
index 5be652c..b17ce68 100644
--- a/src/matchtable.nim
+++ b/src/lzss/matchtable.nim
@@ -15,7 +15,7 @@
15# along with this program. If not, see <https://www.gnu.org/licenses/>. 15# along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16
17import tables, lists 17import tables, lists
18import polyfill 18import listpolyfill
19 19
20type MatchTable*[K, V] = 20type MatchTable*[K, V] =
21 TableRef[K, SinglyLinkedList[V]] 21 TableRef[K, SinglyLinkedList[V]]
@@ -28,5 +28,5 @@ proc matchList*[K, V](matchTable: MatchTable[K, V], pattern: K): SinglyLinkedLis
28 28
29proc addMatch*[K, V](matchTable: MatchTable[K, V], pattern: K, value: V) = 29proc addMatch*[K, V](matchTable: MatchTable[K, V], pattern: K, value: V) =
30 var matchList = matchTable.matchList(pattern) 30 var matchList = matchTable.matchList(pattern)
31 polyfill.prepend(matchList, value) 31 listpolyfill.prepend(matchList, value)
32 matchTable[pattern] = matchList 32 matchTable[pattern] = matchList