mirror of https://github.com/webpack/webpack.git
inline flush, reduce bulk size
This commit is contained in:
parent
a0ef93f939
commit
6b40b1699e
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const BULK_SIZE = 10000;
|
const BULK_SIZE = 1000;
|
||||||
|
|
||||||
class BulkUpdateDecorator {
|
class BulkUpdateDecorator {
|
||||||
constructor(hash) {
|
constructor(hash) {
|
||||||
|
|
@ -14,26 +14,25 @@ class BulkUpdateDecorator {
|
||||||
|
|
||||||
update(data, inputEncoding) {
|
update(data, inputEncoding) {
|
||||||
if(inputEncoding !== undefined || typeof data !== "string" || data.length > BULK_SIZE) {
|
if(inputEncoding !== undefined || typeof data !== "string" || data.length > BULK_SIZE) {
|
||||||
if(this.buffer.length > 0)
|
if(this.buffer.length > 0) {
|
||||||
this._flush();
|
this.hash.update(this.buffer);
|
||||||
|
this.buffer = "";
|
||||||
|
}
|
||||||
this.hash.update(data, inputEncoding);
|
this.hash.update(data, inputEncoding);
|
||||||
} else {
|
} else {
|
||||||
this.buffer += data;
|
this.buffer += data;
|
||||||
if(this.buffer.length > BULK_SIZE) {
|
if(this.buffer.length > BULK_SIZE) {
|
||||||
this._flush();
|
this.hash.update(this.buffer);
|
||||||
|
this.buffer = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
_flush() {
|
|
||||||
this.hash.update(this.buffer);
|
|
||||||
this.buffer = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
digest(encoding) {
|
digest(encoding) {
|
||||||
if(this.buffer.length > 0)
|
if(this.buffer.length > 0) {
|
||||||
this._flush();
|
this.hash.update(this.buffer);
|
||||||
|
}
|
||||||
return this.hash.digest(encoding);
|
return this.hash.digest(encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue