Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
858f0b4d
Commit
858f0b4d
authored
Jan 23, 2012
by
Ivan Krasin
Committed by
Russ Cox
Jan 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compress/flate: delete unused util functions.
R=rsc CC=golang-dev
https://golang.org/cl/5555071
parent
280d85a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
81 deletions
+22
-81
src/pkg/compress/flate/Makefile
src/pkg/compress/flate/Makefile
+0
-1
src/pkg/compress/flate/huffman_bit_writer.go
src/pkg/compress/flate/huffman_bit_writer.go
+19
-7
src/pkg/compress/flate/huffman_code.go
src/pkg/compress/flate/huffman_code.go
+3
-1
src/pkg/compress/flate/util.go
src/pkg/compress/flate/util.go
+0
-72
No files found.
src/pkg/compress/flate/Makefile
View file @
858f0b4d
...
@@ -12,6 +12,5 @@ GOFILES=\
...
@@ -12,6 +12,5 @@ GOFILES=\
inflate.go
\
inflate.go
\
reverse_bits.go
\
reverse_bits.go
\
token.go
\
token.go
\
util.go
\
include
../../../Make.pkg
include
../../../Make.pkg
src/pkg/compress/flate/huffman_bit_writer.go
View file @
858f0b4d
...
@@ -193,15 +193,17 @@ func (w *huffmanBitWriter) writeBytes(bytes []byte) {
...
@@ -193,15 +193,17 @@ func (w *huffmanBitWriter) writeBytes(bytes []byte) {
// numLiterals The number of literals in literalEncoding
// numLiterals The number of literals in literalEncoding
// numOffsets The number of offsets in offsetEncoding
// numOffsets The number of offsets in offsetEncoding
func
(
w
*
huffmanBitWriter
)
generateCodegen
(
numLiterals
int
,
numOffsets
int
)
{
func
(
w
*
huffmanBitWriter
)
generateCodegen
(
numLiterals
int
,
numOffsets
int
)
{
fillInt32s
(
w
.
codegenFreq
,
0
)
for
i
:=
range
w
.
codegenFreq
{
w
.
codegenFreq
[
i
]
=
0
}
// Note that we are using codegen both as a temporary variable for holding
// Note that we are using codegen both as a temporary variable for holding
// a copy of the frequencies, and as the place where we put the result.
// a copy of the frequencies, and as the place where we put the result.
// This is fine because the output is always shorter than the input used
// This is fine because the output is always shorter than the input used
// so far.
// so far.
codegen
:=
w
.
codegen
// cache
codegen
:=
w
.
codegen
// cache
// Copy the concatenated code sizes to codegen. Put a marker at the end.
// Copy the concatenated code sizes to codegen. Put a marker at the end.
copy
Uint8s
(
codegen
[
0
:
numLiterals
],
w
.
literalEncoding
.
codeBits
)
copy
(
codegen
[
0
:
numLiterals
],
w
.
literalEncoding
.
codeBits
)
copy
Uint8s
(
codegen
[
numLiterals
:
numLiterals
+
numOffsets
],
w
.
offsetEncoding
.
codeBits
)
copy
(
codegen
[
numLiterals
:
numLiterals
+
numOffsets
],
w
.
offsetEncoding
.
codeBits
)
codegen
[
numLiterals
+
numOffsets
]
=
badCode
codegen
[
numLiterals
+
numOffsets
]
=
badCode
size
:=
codegen
[
0
]
size
:=
codegen
[
0
]
...
@@ -222,7 +224,10 @@ func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
...
@@ -222,7 +224,10 @@ func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
w
.
codegenFreq
[
size
]
++
w
.
codegenFreq
[
size
]
++
count
--
count
--
for
count
>=
3
{
for
count
>=
3
{
n
:=
min
(
count
,
6
)
n
:=
6
if
n
>
count
{
n
=
count
}
codegen
[
outIndex
]
=
16
codegen
[
outIndex
]
=
16
outIndex
++
outIndex
++
codegen
[
outIndex
]
=
uint8
(
n
-
3
)
codegen
[
outIndex
]
=
uint8
(
n
-
3
)
...
@@ -232,7 +237,10 @@ func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
...
@@ -232,7 +237,10 @@ func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int) {
}
}
}
else
{
}
else
{
for
count
>=
11
{
for
count
>=
11
{
n
:=
min
(
count
,
138
)
n
:=
138
if
n
>
count
{
n
=
count
}
codegen
[
outIndex
]
=
18
codegen
[
outIndex
]
=
18
outIndex
++
outIndex
++
codegen
[
outIndex
]
=
uint8
(
n
-
11
)
codegen
[
outIndex
]
=
uint8
(
n
-
11
)
...
@@ -351,8 +359,12 @@ func (w *huffmanBitWriter) writeBlock(tokens []token, eof bool, input []byte) {
...
@@ -351,8 +359,12 @@ func (w *huffmanBitWriter) writeBlock(tokens []token, eof bool, input []byte) {
if
w
.
err
!=
nil
{
if
w
.
err
!=
nil
{
return
return
}
}
fillInt32s
(
w
.
literalFreq
,
0
)
for
i
:=
range
w
.
literalFreq
{
fillInt32s
(
w
.
offsetFreq
,
0
)
w
.
literalFreq
[
i
]
=
0
}
for
i
:=
range
w
.
offsetFreq
{
w
.
offsetFreq
[
i
]
=
0
}
n
:=
len
(
tokens
)
n
:=
len
(
tokens
)
tokens
=
tokens
[
0
:
n
+
1
]
tokens
=
tokens
[
0
:
n
+
1
]
...
...
src/pkg/compress/flate/huffman_code.go
View file @
858f0b4d
...
@@ -195,7 +195,9 @@ func (h *huffmanEncoder) bitCounts(list []literalNode, maxBits int32) []int32 {
...
@@ -195,7 +195,9 @@ func (h *huffmanEncoder) bitCounts(list []literalNode, maxBits int32) []int32 {
// The tree can't have greater depth than n - 1, no matter what. This
// The tree can't have greater depth than n - 1, no matter what. This
// saves a little bit of work in some small cases
// saves a little bit of work in some small cases
maxBits
=
minInt32
(
maxBits
,
n
-
1
)
if
maxBits
>
n
-
1
{
maxBits
=
n
-
1
}
// Create information about each of the levels.
// Create information about each of the levels.
// A bogus "Level 0" whose sole purpose is so that
// A bogus "Level 0" whose sole purpose is so that
...
...
src/pkg/compress/flate/util.go
deleted
100644 → 0
View file @
280d85a8
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
flate
func
min
(
left
int
,
right
int
)
int
{
if
left
<
right
{
return
left
}
return
right
}
func
minInt32
(
left
int32
,
right
int32
)
int32
{
if
left
<
right
{
return
left
}
return
right
}
func
max
(
left
int
,
right
int
)
int
{
if
left
>
right
{
return
left
}
return
right
}
func
fillInts
(
a
[]
int
,
value
int
)
{
for
i
:=
range
a
{
a
[
i
]
=
value
}
}
func
fillInt32s
(
a
[]
int32
,
value
int32
)
{
for
i
:=
range
a
{
a
[
i
]
=
value
}
}
func
fillBytes
(
a
[]
byte
,
value
byte
)
{
for
i
:=
range
a
{
a
[
i
]
=
value
}
}
func
fillInt8s
(
a
[]
int8
,
value
int8
)
{
for
i
:=
range
a
{
a
[
i
]
=
value
}
}
func
fillUint8s
(
a
[]
uint8
,
value
uint8
)
{
for
i
:=
range
a
{
a
[
i
]
=
value
}
}
func
copyInt8s
(
dst
[]
int8
,
src
[]
int8
)
int
{
cnt
:=
min
(
len
(
dst
),
len
(
src
))
for
i
:=
0
;
i
<
cnt
;
i
++
{
dst
[
i
]
=
src
[
i
]
}
return
cnt
}
func
copyUint8s
(
dst
[]
uint8
,
src
[]
uint8
)
int
{
cnt
:=
min
(
len
(
dst
),
len
(
src
))
for
i
:=
0
;
i
<
cnt
;
i
++
{
dst
[
i
]
=
src
[
i
]
}
return
cnt
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment