Skip to content

Commit

Permalink
stream: remove LazyTransform
Browse files Browse the repository at this point in the history
No longer necessary given recent stream and event optimziations.

Refs: nodejs#50428
Refs: nodejs#50439

PR-URL: nodejs#50440
  • Loading branch information
ronag committed Oct 29, 2023
1 parent 2aaa21f commit 06c89b4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 67 deletions.
22 changes: 22 additions & 0 deletions benchmark/crypto/hash-stream-creation2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Creation benchmark
// creates a single hasher, then pushes a minimal data through it
'use strict';
const common = require('../common.js');
const crypto = require('crypto');

const bench = common.createBenchmark(main, {
n: [10e3],
algo: ['md5' ],
});

const buf = Buffer.alloc(4);

function main({ algo, n }) {
bench.start();
for (let i = 0; i < n; ++i) {
const h = crypto.createHash(algo);
h.end(buf)
}
bench.end(n);
}

2 changes: 0 additions & 2 deletions lib/internal/crypto/cipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ const {

const assert = require('internal/assert');

const LazyTransform = require('internal/streams/lazy_transform');

const { normalizeEncoding } = require('internal/util');

const { StringDecoder } = require('string_decoder');
Expand Down
14 changes: 7 additions & 7 deletions lib/internal/crypto/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const {
isArrayBufferView,
} = require('internal/util/types');

const LazyTransform = require('internal/streams/lazy_transform');
const Transform = require('internal/streams/transform');

const kState = Symbol('kState');
const kFinalized = Symbol('kFinalized');
Expand All @@ -69,11 +69,11 @@ function Hash(algorithm, options) {
this[kState] = {
[kFinalized]: false,
};
ReflectApply(LazyTransform, this, [options]);
ReflectApply(Transform, this, [options]);
}

ObjectSetPrototypeOf(Hash.prototype, LazyTransform.prototype);
ObjectSetPrototypeOf(Hash, LazyTransform);
ObjectSetPrototypeOf(Hash.prototype, Transform.prototype);
ObjectSetPrototypeOf(Hash, Transform);

Hash.prototype.copy = function copy(options) {
const state = this[kState];
Expand Down Expand Up @@ -133,11 +133,11 @@ function Hmac(hmac, key, options) {
this[kState] = {
[kFinalized]: false,
};
ReflectApply(LazyTransform, this, [options]);
ReflectApply(Transform, this, [options]);
}

ObjectSetPrototypeOf(Hmac.prototype, LazyTransform.prototype);
ObjectSetPrototypeOf(Hmac, LazyTransform);
ObjectSetPrototypeOf(Hmac.prototype, Transform.prototype);
ObjectSetPrototypeOf(Hmac, Transform);

Hmac.prototype.update = Hash.prototype.update;

Expand Down
57 changes: 0 additions & 57 deletions lib/internal/streams/lazy_transform.js

This file was deleted.

1 change: 0 additions & 1 deletion src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ BuiltinLoader::BuiltinCategories BuiltinLoader::GetBuiltinCategories() const {
"internal/tls/parse-cert-string", "internal/tls/secure-context",
"internal/http2/core", "internal/http2/compat",
"internal/policy/manifest", "internal/process/policy",
"internal/streams/lazy_transform",
#endif // !HAVE_OPENSSL
"sys", // Deprecated.
"wasi", // Experimental.
Expand Down

0 comments on commit 06c89b4

Please sign in to comment.