Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dd91c1d

Browse filesBrowse files
Gino NottoMylesBorins
authored andcommitted
src: change macro to fn
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>
1 parent af6528a commit dd91c1d
Copy full SHA for dd91c1d

File tree

Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Collapse file

‎src/base64.h‎

Copy file name to clipboardExpand all lines: src/base64.h
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
namespace node {
1212
//// Base 64 ////
13-
#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4)
14-
13+
static inline constexpr size_t base64_encoded_size(size_t size) {
14+
return ((size + 2 - ((size + 2) % 3)) / 3 * 4);
15+
}
1516

1617
// Doesn't check for padding at the end. Can be 1-2 bytes over.
1718
static inline size_t base64_decoded_size_fast(size_t size) {
@@ -48,8 +49,9 @@ size_t base64_decoded_size(const TypeName* src, size_t size) {
4849
extern const int8_t unbase64_table[256];
4950

5051

51-
#define unbase64(x) \
52-
static_cast<uint8_t>(unbase64_table[static_cast<uint8_t>(x)])
52+
inline static int8_t unbase64(uint8_t x) {
53+
return unbase64_table[x];
54+
}
5355

5456

5557
template <typename TypeName>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.