Conversation
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations.
addaleax
left a comment
There was a problem hiding this comment.
Any reason for marking this WIP? It looks good to me :)
src/inspector_socket.cc
Outdated
| FRAME_OK, FRAME_INCOMPLETE, FRAME_CLOSE, FRAME_ERROR | ||
| }; | ||
|
|
||
|
|
There was a problem hiding this comment.
I think this is an unrelated whitespace change?
|
Hello @ginonott and thank you for your contribution 🥇 BTW: So that this submission could be attributed to you properly, you might want to make sure your GitHub email, and local git email are set up to your liking (Ref: https://help.github.com/articles/setting-your-commit-email-address-on-github/) |
| //// Base 64 //// | ||
| #define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4) | ||
|
|
||
| static inline constexpr size_t base64_encoded_size(size_t size) { |
There was a problem hiding this comment.
constexpr implies inline, so no need to specify inline
There was a problem hiding this comment.
https://en.cppreference.com/w/cpp/language/constexpr says
A constexpr specifier used in a function or static member variable (since C++17) declaration implies inline
We are not yet at C++17, right? IINW, We are still at C++14.
There was a problem hiding this comment.
CPPReference is tricky to read. It's only the static member variable (since C++17) part that is the addition to C++17 (see this change)
In C++11 there were no constexpr static member variables, they were added in C++17.
src/inspector_socket.cc
Outdated
| FRAME_OK, FRAME_INCOMPLETE, FRAME_CLOSE, FRAME_ERROR | ||
| }; | ||
|
|
||
|
|
There was a problem hiding this comment.
Unneeded whitespace change.
|
|
||
| #define unbase64(x) \ | ||
| static_cast<uint8_t>(unbase64_table[static_cast<uint8_t>(x)]) | ||
| inline static int8_t unbase64(uint8_t x) { |
There was a problem hiding this comment.
IIUC if you declare unbase64_table as constexpr you could declare this function as constexpr as well.
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: nodejs#23603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: nodejs#23603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: #23603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: #23603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: #23603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: #23603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size is a constexpr to be used in function declarations. PR-URL: #23603 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Change base64_encoded_size and unbase64 to inline functions. The base64_encoded_size
is a constexpr to be used in function declarations.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes