FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

stream: do not chunk strings and Buffer in Readable.from. by mcollina · Pull Request #30912 · nodejs/node · GitHub

/ node Public

stream: do not chunk strings and Buffer in Readable.from. - #30912

Closed
mcollina wants to merge 1 commit into
nodejs:masterfrom
mcollina:readable-from-fast-strings
Closed

stream: do not chunk strings and Buffer in Readable.from.#30912
mcollina wants to merge 1 commit into
nodejs:masterfrom
mcollina:readable-from-fast-strings

Conversation

Copy link
Copy Markdown
Member

This PR makes Readable.from() to not iterate over strings and buffers to avoid unnecessary overhead.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Comment thread lib/internal/streams/from.js Outdated

ronag Dec 12, 2019
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

nit, Not sure of the purpose here, but wouldn't objectMode: false make more sense here as a default? Or is that breaking?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would keep it consistent with the rest. Also, it would change the encoding, so possibly it's not a good idea.

Copy link
Copy Markdown
Member

This does change behaviour when a buffer is passed, is that intentional?

Copy link
Copy Markdown
Member Author

This does change behaviour when a buffer is passed, is that intentional?

Yes, instead of emitting one byte at a time, we will push through the full chunk. This will remove a lot of overhead when using this API.

targos commented Dec 12, 2019

Copy link
Copy Markdown
Member

@mcollina yes, but instead of emitting numbers, it now emits a Buffer

Copy link
Copy Markdown
Member Author

Ouch. I would consider this a bug :/.

Comment thread lib/internal/streams/from.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should we check for Stream._isUint8Array as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That would only be okay if we turn off object mode, I think

Copy link
Copy Markdown
Member

Ouch. I would consider this a bug :/.

I would agree, but could you document that Buffers are treated differently from other iterables in that case?

mcollina force-pushed the readable-from-fast-strings branch from 378e505 to 019d0d0 Compare December 13, 2019 20:40
mcollina force-pushed the readable-from-fast-strings branch from 019d0d0 to 4dbdd43 Compare December 13, 2019 21:17

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

This comment has been minimized.

Trott commented Dec 14, 2019

Copy link
Copy Markdown
Member

Landed in f8018f2

Trott closed this Dec 14, 2019
Trott pushed a commit that referenced this pull request Dec 14, 2019
PR-URL: #30912
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins pushed a commit that referenced this pull request Dec 17, 2019
PR-URL: #30912
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
MylesBorins mentioned this pull request Dec 17, 2019
targos pushed a commit that referenced this pull request Jan 14, 2020
PR-URL: #30912
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
PR-URL: #30912
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

7 participants


Back | FazBrowse Home | New Git URL