-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
src: clean up WHATWG URL parser, round 2 #12251
Conversation
src/node_url.cc
Outdated
template <typename T, \ | ||
typename = typename std::enable_if<std::is_integral<T>::value && \ | ||
sizeof(T) >= n / 8, T>::type> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh this does feel a bit like overkill ;) Plain template <typename T> static inline
s should do the job, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, actually, as much as I love templates… maybe this is not the right time to use them? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still prefer to have some basic type-checking, but I agree the is_integral
check is probably overkill. Opted for a static_assert
on sizeof(T)
instead.
src/node_url.cc
Outdated
// Must return true if the character is to be percent-encoded | ||
typedef bool (*must_escape_cb)(const unsigned char ch); | ||
static inline bool BitAt(const uint8_t a[], const uint8_t i) { | ||
return !!(a[i >> 3] & (1 << (i & 7))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw you don’t need to do the !!
if you’re returning a bool
anyway
I have not yet had a chance to go into a full review but things look good so far. |
@TimothyGu This would need a rebase :) |
84ea5f8
to
cd419d0
Compare
@addaleax done 😺 |
They are unused in the JS layer.
cd419d0
to
e8f1dcc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still LGTM :)
* reduce indentation * refactor URL inlined methods * prefer templates over macros * do not export ARG_* flags in url binding PR-URL: #12251 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in ade80ee |
This batch has some pretty heavy-duty changes, so reviewing commit-by-commit is probably preferred.
Reduce indentation
For some reason the linter never caught it, but in all other source files namespaces do not affect indentation. Link to whitespace-free diff
Refactor
node_url.h
andnode_url.cc
A lot of inlined functions and lookup tables never needed to be in the header. Now that the header is going to be used more frequently in other areas of the codebase, it is best these things go into the actual implementation file.
Prefer templates over macros
Many character checks were implemented as macros. Implement them as templatized inline functions for better type checking.
Do not export
ARG_*
flags in url bindingThey are not used by the JS layer.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src, url