luke
5b0203fbd3
check writer level when use NewWriterLevel
...
Signed-off-by: luke <chenjinguang@huawei.com>
2022-03-10 01:34:15 +00:00
Andy Balholm
1d750214c2
Optimize log2FloorNonZero with math/bits.
2021-09-22 11:21:01 -07:00
zuiwuchang
ec682fbe0a
Rest set writer.err=nil
2021-08-25 10:29:47 +08:00
Andy Balholm
cf8bc3b664
More staticcheck advice.
2021-08-18 18:04:51 -07:00
Andy Balholm
a61eb82231
Follow some advice from staticcheck.
2021-08-12 12:37:09 -07:00
Andy Balholm
e073f0d4ed
Merge branch 'issue22'
2021-07-15 12:01:52 -07:00
Andy Balholm
177b8acd6c
Add test for issue 22.
2021-07-15 12:01:31 -07:00
Andy Balholm
5376c15dde
Retract v1.0.1
2021-05-26 15:10:20 -07:00
Andy Balholm
94609f9606
Revert "Faster bit writing."
...
This reverts commit c3da72aa01
.
With the sample data from issue 22, one byte in the output file is zero
instead of the correct value. For now at least, we'll go back to the old
way of writing bits.
Fixes #22
2021-04-27 10:48:28 -07:00
Andy Balholm
47c0dbab12
Simplify control flow in Reader.Reset.
2021-03-01 09:45:40 -08:00
Mike Faraponov
87d8f4575c
Reduce allocations of buffer for reused readers
2021-03-01 09:42:42 -08:00
Andy Balholm
729edfbcfe
Add documentation link.
...
Fixes #16
2020-08-04 09:53:43 -07:00
oguzyildiz1991
1b06c5640c
Check size of split.lengths instead of a nil check
...
Fixes https://github.com/andybalholm/brotli/issues/14
2020-07-17 09:24:47 -07:00
Andy Balholm
c3da72aa01
Faster bit writing.
...
Replace the functions in write_bits.go with a bitWriter type based on
the compress/flate package.
2020-06-18 18:58:27 -07:00
Andy Balholm
ef7a42160d
Use a 64-bit store in writeBits.
...
This is an optimization that was present in the C version (behind an
ifdef). It gives a nice speed boost to the lower compression levels.
2020-06-06 14:13:21 -07:00
Andy Balholm
097c1c5bc9
Use 32-bit loads in isMatch1 and isMatch5.
2020-05-15 11:17:23 -07:00
Andy Balholm
8f8b18645c
Read multiple bytes in findMatchLengthWithLimit
...
Use 64- or 32-bit loads instead of reading a byte at a time. The
original C source did something like this, in a very C-ish way. It
needed to be simplified to translate it to Go. The exact way this works
was suggested by the assembly code in github.com/golang/snappy.
2020-05-15 10:43:19 -07:00
Erik Dubbelboer
a01a7b12c9
Reuse buffers and objects using sync.Pool
...
This reduces the amount of garbage generated and relieves pressure on
the GC.
For a workload without reusing the Writer (using Writer.Reset) the number of allocations goes from 31 to 9.
While for a workload when you reuse the Writer the number of allocations goes from 25 to 0.
2020-05-10 10:36:19 +02:00
Andy Balholm
e2c5f2109f
Use len and cap instead of num_commands_ and cmd_alloc_size_.
2020-05-08 16:48:16 -07:00
Andy Balholm
4b2775ea5e
Fix some ugly compound literals.
2020-05-08 15:14:47 -07:00
Andy Balholm
b2497e8d72
Revert "Use sort.Sort to sort Huffman trees."
...
This reverts commit 6b5963335e
.
It doesn't really have the performance benefit I thought it did.
2020-05-08 13:52:56 -07:00
Andy Balholm
6b5963335e
Use sort.Sort to sort Huffman trees.
2020-05-07 17:51:21 -07:00
Andy Balholm
7c7a5a10ef
Push output directly to dst instead of buffering.
2020-05-07 17:27:37 -07:00
Andy Balholm
625cbb6f92
Replace storage_size_ with len(storage).
2020-05-07 15:40:58 -07:00
Andy Balholm
f41712f811
Remove unnecessary parameters from encodeData.
...
The pointers passed to out_size and output were always the same,
so there is no need to have them as parameters.
Based on
00ca10b927
and b3ee528567
2020-05-06 17:20:27 -07:00
Andy Balholm
511ca97d30
Benchmark all compression levels.
2020-05-06 16:08:01 -07:00
Andy Balholm
2c14228f02
Preserve w.commands across Reset.
2020-05-05 17:36:16 -07:00
Andy Balholm
cb9be97eb7
Reuse more memory when a Writer is Reset.
2020-05-05 17:18:33 -07:00
Andy Balholm
00ca370ce2
Put full license in bench_test.go
2020-05-05 16:14:45 -07:00
Andy Balholm
3c3658f2fb
A couple of tweaks
2020-05-04 16:09:27 -07:00
Andy Balholm
ac459dee64
Fix excessive allocations if sortHuffmanTreeItems.
...
Fixes #11
2020-05-04 15:04:20 -07:00
Andy Balholm
9fc263f565
Add some benchmarks.
...
These are basically copied from the compress/flate package.
2020-05-04 13:35:04 -07:00
Andy Balholm
b60f0d972e
Copy negotiateContentEncoding.
...
A little copying is better than a little dependency.
Fixes #8
2019-08-21 08:13:43 -07:00
Andy Balholm
ed0fd64940
Fix int overflow in test on 32-bit.
...
On 32-bit systems, the random array indexes were sometimes negative as a
result of converting an int64 to int.
Fixes #7 .
2019-07-25 08:52:43 -07:00
Andy Balholm
71eb68cc46
Preserve compression settings when Writer is reset.
...
Fixes #6
2019-07-04 08:13:24 -07:00
Andy Balholm
5f990b63d2
Add README.
2019-06-21 08:47:22 -07:00
Andy Balholm
5c318f9037
Add HTTPCompressor for HTTP Content-Encoding negotiation.
2019-04-30 14:53:06 -07:00
Andy Balholm
f00818cf36
Fix tests broken by API change.
2019-04-25 09:03:32 -07:00
Andy Balholm
a097b55267
Merge pull request #4 from paolobarbolini/behave-like-compress
...
Make it behave like other compress/ packages
2019-04-25 09:01:22 -07:00
Paolo Barbolini
7ad6b2e5b1
Make brotli behave like official compress/ packages
2019-04-25 17:25:59 +02:00
Andy Balholm
580fdc1cde
Removed unused error
2019-04-25 08:21:22 -07:00
Andy Balholm
1b2ddcf9b7
Merge pull request #2 from shanemhansen/shane-change-struct-scope
...
Lift structs to higher scope
2019-03-29 18:17:44 -04:00
Shane Hansen
f6e5ca9707
gofmt
2019-03-29 15:15:07 -07:00
Shane Hansen
94370e0b46
Lift structs to higher scope
...
Small performance improvement (27%) by re-using search result
structs. Likely the original C version relied on stack allocation here.
2019-03-29 15:12:32 -07:00
Andy Balholm
36f6c9721d
Fix warnings from go vet.
...
FIxes #1
2019-03-26 06:05:46 -04:00
Andy Balholm
45f5d9b05a
Fix negative slice indexes.
2019-03-23 11:17:03 -07:00
Andy Balholm
08371dc992
Use const for constants.
2019-03-21 16:15:39 -07:00
Andy Balholm
52165d4974
Clean up duplicate and misplaced comments.
2019-03-21 15:34:30 -07:00
Andy Balholm
55e85f3f75
Finish un-exporting symbols.
2019-03-15 18:00:20 -07:00
Andy Balholm
4e6528a75b
Remove duplicate kBlockLengthPrefixCode constants.
2019-03-15 17:27:29 -07:00