update README to present XXH3
diff --git a/README.md b/README.md
index 5213b19..323bc6f 100644
--- a/README.md
+++ b/README.md
@@ -98,7 +98,7 @@
Calling xxhash 64-bit variant from a C program :
-```c
+```C
#include "xxhash.h"
unsigned long long calcul_hash(const void* buffer, size_t length)
@@ -110,42 +110,66 @@
```
Using streaming variant is more involved, but makes it possible to provide data in multiple rounds :
-```c
+```C
#include "stdlib.h" /* abort() */
#include "xxhash.h"
unsigned long long calcul_hash_streaming(someCustomType handler)
{
+ /* create a hash state */
XXH64_state_t* const state = XXH64_createState();
if (state==NULL) abort();
- size_t const bufferSize = SOME_VALUE;
+ size_t const bufferSize = SOME_SIZE;
void* const buffer = malloc(bufferSize);
if (buffer==NULL) abort();
+ /* Initialize state with selected seed */
unsigned long long const seed = 0; /* or any other value */
XXH_errorcode const resetResult = XXH64_reset(state, seed);
if (resetResult == XXH_ERROR) abort();
+ /* Feed the state with input data, any size, any number of times */
(...)
while ( /* any condition */ ) {
- size_t const length = get_more_data(buffer, bufferSize, handler); /* undescribed */
- XXH_errorcode const addResult = XXH64_update(state, buffer, length);
- if (addResult == XXH_ERROR) abort();
+ size_t const length = get_more_data(buffer, bufferSize, handler);
+ XXH_errorcode const updateResult = XXH64_update(state, buffer, length);
+ if (updateResult == XXH_ERROR) abort();
(...)
}
-
(...)
- unsigned long long const hash = XXH64_digest(state);
+ /* Get the hash */
+ XXH64_hash_t const hash = XXH64_digest(state);
+
+ /* State can then be re-used; in this example, it is simply freed */
free(buffer);
XXH64_freeState(state);
- return hash;
+ return (unsigned long long)hash;
}
```
+### New experimental hash algorithm
+
+Starting with `v0.7.0`, the library includes a new algorithm, named `XXH3`,
+able to generate 64 and 128-bits hashes.
+
+The new algorithm is much faster than its predecessors,
+for both long and small inputs,
+as can be observed in following graphs :
+
+![XXH3, bargraph](https://github.com/Cyan4973/xxHash/releases/download/graphs/H_bandwidth_bargraph.png)
+
+![XXH3, latency, random size](https://github.com/Cyan4973/xxHash/releases/download/graphs/H_latency_randomS.png)
+
+The algorithm is currently labelled experimental, as it may change in a future version.
+To access it, one need to unlock its declaration using macro `XXH_STATIC_LINKING_ONLY`.
+It can be used for ephemeral data, and for tests, but avoid storing long-term hash values yet.
+`XXH3` will be stabilized in a future version.
+This period will be used to collect users' feedback.
+
### Other programming languages
diff --git a/xxhash.c b/xxhash.c
index 2edd6f8..0fd12ce 100644
--- a/xxhash.c
+++ b/xxhash.c
@@ -1009,10 +1009,10 @@
-/* *******************************************************************
+/* *********************************************************************
* XXH3
* New generation hash designed for speed on small keys and vectorization
-********************************************************************** */
+************************************************************************ */
#include "xxh3.h"