Skip to content

Commit d231236

Browse files
committed
src: make PercentDecode return void
It only returns 0, nor is it likely to have any error conditions in the future. PR-URL: nodejs#11922 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c515a98 commit d231236

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/node_url.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ namespace url {
368368
}
369369

370370
// First, we have to percent decode
371-
if (PercentDecode(input, length, &decoded) < 0)
372-
goto end;
371+
PercentDecode(input, length, &decoded);
373372

374373
// Then we have to punycode toASCII
375374
if (!ToASCII(&decoded, &decoded))

src/node_url.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,11 @@ static inline unsigned hex2bin(const char ch) {
376376
return static_cast<unsigned>(-1);
377377
}
378378

379-
static inline int PercentDecode(const char* input,
380-
size_t len,
381-
std::string* dest) {
379+
static inline void PercentDecode(const char* input,
380+
size_t len,
381+
std::string* dest) {
382382
if (len == 0)
383-
return 0;
383+
return;
384384
dest->reserve(len);
385385
const char* pointer = input;
386386
const char* end = input + len;
@@ -399,11 +399,10 @@ static inline int PercentDecode(const char* input,
399399
unsigned a = hex2bin(pointer[1]);
400400
unsigned b = hex2bin(pointer[2]);
401401
char c = static_cast<char>(a * 16 + b);
402-
*dest += static_cast<char>(c);
402+
*dest += c;
403403
pointer += 3;
404404
}
405405
}
406-
return 0;
407406
}
408407

409408
#define SPECIALS(XX) \

0 commit comments

Comments
 (0)