mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-19 14:48:59 +00:00
Don't use asmcrypto's streaming API when not necessary
Optimization for Firefox
This commit is contained in:
@@ -43,10 +43,14 @@ function hashjs_hash(hash) {
|
||||
|
||||
function asmcrypto_hash(hash) {
|
||||
return function(data) {
|
||||
const hashInstance = new hash();
|
||||
return stream.transform(data, value => {
|
||||
hashInstance.process(value);
|
||||
}, () => hashInstance.finish().result);
|
||||
if (util.isStream(data)) {
|
||||
const hashInstance = new hash();
|
||||
return stream.transform(data, value => {
|
||||
hashInstance.process(value);
|
||||
}, () => hashInstance.finish().result);
|
||||
} else {
|
||||
return hash.bytes(data);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user