Skip to content

Commit fd611cc

Browse files
tniessenRafaelGSS
authored andcommitted
src: remove base64_select_table and base64_table
node::base64_encode() uses ::base64_encode() when the mode is Base64Mode::NORMAL, so base64_select_table is only ever called for Base64Mode::URL and thus only ever returns base64_table_url, but never base64_table. Also move base64_table_url into base64-inl.h. PR-URL: #44425 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 35cbe1a commit fd611cc

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/base64-inl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
namespace node {
1111

12+
static constexpr char base64_table_url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
13+
"abcdefghijklmnopqrstuvwxyz"
14+
"0123456789-_";
15+
1216
extern const int8_t unbase64_table[256];
1317

1418

@@ -144,7 +148,7 @@ inline size_t base64_encode(const char* src,
144148
unsigned k;
145149
unsigned n;
146150

147-
const char* table = base64_select_table(mode);
151+
const char* table = base64_table_url;
148152

149153
i = 0;
150154
k = 0;

src/base64.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,6 @@ enum class Base64Mode {
1717
URL
1818
};
1919

20-
static constexpr char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
21-
"abcdefghijklmnopqrstuvwxyz"
22-
"0123456789+/";
23-
24-
static constexpr char base64_table_url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
25-
"abcdefghijklmnopqrstuvwxyz"
26-
"0123456789-_";
27-
28-
static inline const char* base64_select_table(Base64Mode mode) {
29-
switch (mode) {
30-
case Base64Mode::NORMAL: return base64_table;
31-
case Base64Mode::URL: return base64_table_url;
32-
default: UNREACHABLE();
33-
}
34-
}
35-
3620
static inline constexpr size_t base64_encoded_size(
3721
size_t size,
3822
Base64Mode mode = Base64Mode::NORMAL) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy