Update README.md

pull/1/head
Clyne 4 years ago committed by GitHub
parent 3d514db570
commit d405af197f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,25 +8,20 @@ Compression is achieved using [Huffman coding](https://en.wikipedia.org/wiki/Huf
**1. Text configurations (e.g. JSON)** **1. Text configurations (e.g. JSON)**
A ~3.5kB string of JSON can be compressed down ~2.5kB ([see it on Godbolt](https://godbolt.org/z/1MzG1v)). A ~3.5kB string of JSON can be compressed down ~2.5kB ([see it on Godbolt](https://godbolt.org/z/rqWf4v)).
**2. Scripts (e.g. Lisp)** **2. Scripts (e.g. Lisp)**
A ~40 line comment-including sample of Lisp can be reduced from 1,662 bytes to 1,244 (418 bytes saved) ([Godbolt](https://godbolt.org/z/jcnKza)). A ~40 line comment-including sample of Lisp can be reduced from 1,662 bytes to 1,244 (418 bytes saved) ([Godbolt](https://godbolt.org/z/Kbenbh)).
## How to Use ## How to Use
```cpp ```cpp
#include "consteval_huffman.hpp" #include "consteval_huffman.hpp"
constexpr static const char some_data_raw[] = /* insert text here */; // Using the _huffman suffix creates an object with the compressed data.
// If data is not smaller after compression, the object will keep the data uncompressed.
// Creates an object with the compressed data constinit auto some_data = "This is my string of data"_huffman;
// If data is not smaller after compression, huffman_compress will keep the data uncompressed
constinit static const auto some_data = huffman_compress<some_data_raw>();
// Or, with a set data length:
// ... some_data = huffman_compress<some_data_raw, 1500>();
int main() int main()
{ {

Loading…
Cancel
Save