Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use .push.apply instead of concat in Mux _readIncoming #658

Merged
merged 2 commits into from May 15, 2022

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Nov 4, 2021

Also
remove unused require
remove unused self variable

#657

Should reduce memory footprint and performance

@@ -79,7 +77,7 @@ Mux.prototype._readIncoming = function() {
}
else { // ran out of room
assert(this.newStreams.length > 0, "Expect some new streams to remain");
this.oldStreams = this.oldStreams.concat(this.newStreams);
Array.prototype.push.apply(this.oldStreams, this.newStreams);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why prototype push is used instead of this.oldstreams.push?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I can not test it, but you could do a this.oldstreams.push.apply(this.newstreams)?

I think I did this to make it clear that it does not instantiate a intermediary Array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stackoverflow.com/questions/15444242/why-doesnt-array-push-apply-work

I think this was the reason. I don't want to reference this.oldstreams twice.

@cressie176 cressie176 merged commit 8dfbe76 into amqp-node:main May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants