From 019a20adb5914211814c2146fd457bb2ad607203 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Thu, 16 Mar 2017 16:46:12 -0700 Subject: [PATCH] src: make PercentDecode return void It only returns 0, nor is it likely to have any error conditions in the future. PR-URL: https://github.com/nodejs/node/pull/11922 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung Reviewed-By: James M Snell --- src/node_url.cc | 3 +-- src/node_url.h | 11 +++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/node_url.cc b/src/node_url.cc index 5027399e89dd71..762f8723106198 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -375,8 +375,7 @@ namespace url { } // First, we have to percent decode - if (PercentDecode(input, length, &decoded) < 0) - goto end; + PercentDecode(input, length, &decoded); // If there are any invalid UTF8 byte sequences, we have to fail. // Unfortunately this means iterating through the string and checking diff --git a/src/node_url.h b/src/node_url.h index 198c29938b7d22..ba05cd6fed65d2 100644 --- a/src/node_url.h +++ b/src/node_url.h @@ -376,11 +376,11 @@ static inline unsigned hex2bin(const char ch) { return static_cast(-1); } -static inline int PercentDecode(const char* input, - size_t len, - std::string* dest) { +static inline void PercentDecode(const char* input, + size_t len, + std::string* dest) { if (len == 0) - return 0; + return; dest->reserve(len); const char* pointer = input; const char* end = input + len; @@ -399,11 +399,10 @@ static inline int PercentDecode(const char* input, unsigned a = hex2bin(pointer[1]); unsigned b = hex2bin(pointer[2]); char c = static_cast(a * 16 + b); - *dest += static_cast(c); + *dest += c; pointer += 3; } } - return 0; } #define SPECIALS(XX) \