[v6.x] src: some refactoring of node_url.cc#18324
Closed
addaleax wants to merge 6 commits intonodejs:v6.x-stagingfrom
Closed
[v6.x] src: some refactoring of node_url.cc#18324addaleax wants to merge 6 commits intonodejs:v6.x-stagingfrom
addaleax wants to merge 6 commits intonodejs:v6.x-stagingfrom
Conversation
- Remove pointless pointers - Make `WriteHost` take a const argument so that it’s functionality is clear from the signature - Make `FindLongestZeroSequence` templated to accommodate the constness in `WriteHost` and because using `uint16_t` is an articifial, unnecessary restriction - Remove string copying when no copies are needed - Make `PercentDecode` just return its return value - Make `ParseHost` (string-only version) take its constant argument as a constant reference PR-URL: nodejs#17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This helps because `static` doesn’t work for C++ classes, but refactoring `url_host` into a proper C++ class seems the most reasonable soluation for the memory leak fixed by the next commit. PR-URL: nodejs#17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
- Gives `URLHost` a proper destructor that clears memory depending on the type of the host (This fixes a memory leak) - Hide the host type enums and class layout as implementation details - Make the `Parse` methods members of `URLHost` - Turn `WriteHost` into a `ToString()` method on the `URLHost` class - Verify that at the beginning of a parse attempt, the type is set to “failed” - Remove a lot of `goto`s from the source code 🐢🚀 PR-URL: nodejs#17470 Fixes: nodejs#17448 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
`last_piece` pointed to the end of the 8×16 bit array, so `piece_pointer == last_piece` already means that the pointer is not writable any longer. Previously, this still worked most of the time but could result in an out-of-bounds-write. Also, rename `last_piece` to `buffer_end` to avoid this pitfall. PR-URL: nodejs#17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This would require C++11 features that would otherwise not be available on clang + OS X on Node 6.x.
Contributor
|
CI: https://ci.nodejs.org/job/node-test-pull-request/12690/ v6.x-staging CI for comparison: https://ci.nodejs.org/job/node-test-commit/15628/ |
Contributor
|
Looks like the Linter + AIX + linux failures are for real linter bsd aix These failures look unrelated though, so I'm going to dig in and see if these are perhaps known flakes... edit: can't figure out why ci is failing on these... no prior art |
Member
Author
|
@MylesBorins Fixed the linter bits. The TLS failure in particular is a bit worrying, yes… |
TimothyGu
approved these changes
Jan 26, 2018
Member
MylesBorins
pushed a commit
that referenced
this pull request
Feb 5, 2018
- Remove pointless pointers - Make `WriteHost` take a const argument so that it’s functionality is clear from the signature - Make `FindLongestZeroSequence` templated to accommodate the constness in `WriteHost` and because using `uint16_t` is an articifial, unnecessary restriction - Remove string copying when no copies are needed - Make `PercentDecode` just return its return value - Make `ParseHost` (string-only version) take its constant argument as a constant reference Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 5, 2018
- Gives `URLHost` a proper destructor that clears memory depending on the type of the host (This fixes a memory leak) - Hide the host type enums and class layout as implementation details - Make the `Parse` methods members of `URLHost` - Turn `WriteHost` into a `ToString()` method on the `URLHost` class - Verify that at the beginning of a parse attempt, the type is set to “failed” - Remove a lot of `goto`s from the source code 🐢🚀 Backport-PR-URL: #18324 PR-URL: #17470 Fixes: #17448 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 5, 2018
`last_piece` pointed to the end of the 8×16 bit array, so `piece_pointer == last_piece` already means that the pointer is not writable any longer. Previously, this still worked most of the time but could result in an out-of-bounds-write. Also, rename `last_piece` to `buffer_end` to avoid this pitfall. Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 5, 2018
This would require C++11 features that would otherwise not be available on clang + OS X on Node 6.x. PR-URL: #18324 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Contributor
|
landed in 45cb79d...6632a45 |
Contributor
|
btw the tls failure is unrelated and fixed in 75fbd51 |
Merged
MylesBorins
pushed a commit
that referenced
this pull request
Feb 11, 2018
- Remove pointless pointers - Make `WriteHost` take a const argument so that it’s functionality is clear from the signature - Make `FindLongestZeroSequence` templated to accommodate the constness in `WriteHost` and because using `uint16_t` is an articifial, unnecessary restriction - Remove string copying when no copies are needed - Make `PercentDecode` just return its return value - Make `ParseHost` (string-only version) take its constant argument as a constant reference Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 11, 2018
- Gives `URLHost` a proper destructor that clears memory depending on the type of the host (This fixes a memory leak) - Hide the host type enums and class layout as implementation details - Make the `Parse` methods members of `URLHost` - Turn `WriteHost` into a `ToString()` method on the `URLHost` class - Verify that at the beginning of a parse attempt, the type is set to “failed” - Remove a lot of `goto`s from the source code 🐢🚀 Backport-PR-URL: #18324 PR-URL: #17470 Fixes: #17448 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 11, 2018
`last_piece` pointed to the end of the 8×16 bit array, so `piece_pointer == last_piece` already means that the pointer is not writable any longer. Previously, this still worked most of the time but could result in an out-of-bounds-write. Also, rename `last_piece` to `buffer_end` to avoid this pitfall. Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 11, 2018
This would require C++11 features that would otherwise not be available on clang + OS X on Node 6.x. PR-URL: #18324 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 12, 2018
- Remove pointless pointers - Make `WriteHost` take a const argument so that it’s functionality is clear from the signature - Make `FindLongestZeroSequence` templated to accommodate the constness in `WriteHost` and because using `uint16_t` is an articifial, unnecessary restriction - Remove string copying when no copies are needed - Make `PercentDecode` just return its return value - Make `ParseHost` (string-only version) take its constant argument as a constant reference Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 12, 2018
- Gives `URLHost` a proper destructor that clears memory depending on the type of the host (This fixes a memory leak) - Hide the host type enums and class layout as implementation details - Make the `Parse` methods members of `URLHost` - Turn `WriteHost` into a `ToString()` method on the `URLHost` class - Verify that at the beginning of a parse attempt, the type is set to “failed” - Remove a lot of `goto`s from the source code 🐢🚀 Backport-PR-URL: #18324 PR-URL: #17470 Fixes: #17448 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 12, 2018
`last_piece` pointed to the end of the 8×16 bit array, so `piece_pointer == last_piece` already means that the pointer is not writable any longer. Previously, this still worked most of the time but could result in an out-of-bounds-write. Also, rename `last_piece` to `buffer_end` to avoid this pitfall. Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 12, 2018
This would require C++11 features that would otherwise not be available on clang + OS X on Node 6.x. PR-URL: #18324 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 13, 2018
- Remove pointless pointers - Make `WriteHost` take a const argument so that it’s functionality is clear from the signature - Make `FindLongestZeroSequence` templated to accommodate the constness in `WriteHost` and because using `uint16_t` is an articifial, unnecessary restriction - Remove string copying when no copies are needed - Make `PercentDecode` just return its return value - Make `ParseHost` (string-only version) take its constant argument as a constant reference Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 13, 2018
- Gives `URLHost` a proper destructor that clears memory depending on the type of the host (This fixes a memory leak) - Hide the host type enums and class layout as implementation details - Make the `Parse` methods members of `URLHost` - Turn `WriteHost` into a `ToString()` method on the `URLHost` class - Verify that at the beginning of a parse attempt, the type is set to “failed” - Remove a lot of `goto`s from the source code 🐢🚀 Backport-PR-URL: #18324 PR-URL: #17470 Fixes: #17448 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 13, 2018
`last_piece` pointed to the end of the 8×16 bit array, so `piece_pointer == last_piece` already means that the pointer is not writable any longer. Previously, this still worked most of the time but could result in an out-of-bounds-write. Also, rename `last_piece` to `buffer_end` to avoid this pitfall. Backport-PR-URL: #18324 PR-URL: #17470 Reviewed-By: Timothy Gu <timothygu99@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Feb 13, 2018
This would require C++11 features that would otherwise not be available on clang + OS X on Node 6.x. PR-URL: #18324 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #17470 with one extra commit for making this compile with clang on OS X (otherwise these are clean cherry-picks).
@MylesBorins