Final ZSTD updates from Kiwix JS

Former-commit-id: c0cac1707aa66b1b96c088507214bf36e04e3500 [formerly d97490337d51109a77f6c781d8639d2941d8301f [formerly f26b919e08342bdb3de32461dae23fb732181351]]
Former-commit-id: 4374ee01d5f22592944232b79668eb584487ca94
Former-commit-id: 9f4339335f1031c3bcd77e70e16f892bd1f8ba26
This commit is contained in:
Jaifroid 2020-09-29 20:16:48 +01:00
parent 2bbaf7307e
commit 4a834f7e9f
3 changed files with 14 additions and 14 deletions

View File

@ -455,14 +455,16 @@
</p>
<p>Main libraries and resources used:</p>
<ul>
<li><a href="https://jquery.com/" target="_blank">jQuery</a> 3, released under the <a href="https://jquery.org/license" target="_blank">MIT licence</a></li>
<li><a href="https://getbootstrap.com/" target="_blank">Bootstrap</a> 3, released under the <a href="https://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache licence 2.0</a>, which includes icons from <a href="https://glyphicons.com/">Glyphicons</a></li>
<li><a href="https://requirejs.org/" target="_blank">RequireJS</a> 2, released under the <a href="https://github.com/jrburke/requirejs/blob/master/LICENSE" target="_blank">MIT licence or new BSD licence</a></li>
<li><a href="https://qunitjs.com/" target="_blank">QUnit</a> 2, released under the <a href="https://jquery.org/license" target="_blank">MIT licence</a></li>
<li>Kiwix logo from <a href="https://www.kiwix.org/" target="_blank">kiwix.org</a>, released under the <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons Attribution Share Alike</a></li>
<li>OpenZIM specifications from <a href="https://wiki.openzim.org/wiki/OpenZIM" target="_blank">www.openzim.org</a>, released under the <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons Attribution Share Alike</a></li>
<li>Emscripten to generate a XZ decompressor in javascript : <a href="https://github.com/kripken/emscripten" target="_blank">https://github.com/kripken/emscripten</a>, released under the <a href="https://github.com/kripken/emscripten" target="_blank">MIT licence</a></li>
<li><a href="https://jquery.com/" target="_blank">jQuery</a> 3, released under the <a href="https://jquery.org/license" target="_blank">MIT Licence</a></li>
<li><a href="https://getbootstrap.com/" target="_blank">Bootstrap</a> 3, released under the <a href="https://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache Licence 2.0</a>, which includes icons from <a href="https://glyphicons.com/">Glyphicons</a></li>
<li><a href="https://requirejs.org/" target="_blank">RequireJS</a> 2, released under the <a href="https://github.com/jrburke/requirejs/blob/master/LICENSE" target="_blank">MIT licence or new BSD Licence</a></li>
<li><a href="https://qunitjs.com/" target="_blank">QUnit</a> 2, released under the <a href="https://jquery.org/license" target="_blank">MIT Licence</a></li>
<li>Kiwix logo from <a href="https://www.kiwix.org/" target="_blank">kiwix.org</a>, released under the <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons Attribution Share Alike Licence</a></li>
<li>OpenZIM specifications from <a href="https://wiki.openzim.org/wiki/OpenZIM" target="_blank">www.openzim.org</a>, released under the <a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons Attribution Share Alike Licence</a></li>
<li>Emscripten to generate a XZ decompressor in javascript : <a href="https://github.com/kripken/emscripten" target="_blank">https://github.com/kripken/emscripten</a>, released under the <a href="https://github.com/kripken/emscripten" target="_blank">MIT Licence</a></li>
<li><a href="https://tukaani.org/xz/embedded.html" target="_blank">XZ Embedded</a> (the XZ library converted to Javascript with Emscripten), in public domain</li>
<li>The <a href="https://github.com/facebook/zstd" target="_blank">Zstandard library</a>, released under a <a href="https://github.com/facebook/zstd/blob/dev/LICENSE" target="_blank">BSD Licence</a> and a <a href="https://github.com/facebook/zstd/blob/dev/COPYING" target="_blank">GPLv2 Copying Licence</a></li>
<li><a href="https://katex.org/" target="_blank">KaTeX</a> for typesetting mathematical and chemical equations, released under the <a href="https://github.com/KaTeX/KaTeX/blob/master/LICENSE" target="_blank">MIT licence</a></li>
<li><a href="https://www.the-art-of-web.com/javascript/search-highlight/" target="_blank">Hilitor</a> for finding and hilighting text inside an article, released under <a href="https://www.the-art-of-web.com/copyright.html" target="_blank">this licence</a></li>
</ul>

View File

@ -191,10 +191,7 @@ define(['xzdec_wrapper', 'zstddec_wrapper', 'util', 'utf8', 'q', 'zimDirEntry'],
return that._readSlice(clusterOffset, 1).then(function(compressionType) {
var decompressor;
var plainBlobReader = function(offset, size) {
// DEV: old algorithm merely returned requested data size
// but I believe we need to check that we are not reading beyond the end of the cluster
// Is this an oversight in original code or an unnecessary protection?
// return that._readSlice(clusterOffset + 1 + offset, size);
// Check that we are not reading beyond the end of the cluster
var offsetStart = clusterOffset + 1 + offset;
if ( offsetStart < nextCluster) {
// Gratuitous parentheses added for legibility

View File

@ -48,9 +48,10 @@ define(['q', 'zstddec'], function(Q) {
// Get a permanent decoder handle (pointer to control structure)
// NB there is no need to change this handle even between ZIM loads: zstddeclib encourages re-using assigned structures
zd._decHandle = zd._ZSTD_createDStream();
// DEV set chunkSize according to memory environment; for systems with plenty of memory,
// zd can provide a max recommended size with
// In-built function below provides a max recommended chunk size
zd._chunkSize = zd._ZSTD_DStreamInSize();
// Change _chunkSize if you need a more conservative memory environment, but you may need to experiment with INITIAL_MEMORY
// in zstddec.js (see below) for this to make any difference
// zd._chunkSize = 5 * 1024;
// Initialize inBuffer
@ -259,4 +260,4 @@ define(['q', 'zstddec'], function(Q) {
return {
Decompressor: Decompressor
};
});
});