summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/base/escape.cc16
-rw-r--r--net/base/net_util.cc9
2 files changed, 4 insertions, 21 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc
index d9bfcee..3c39f95 100644
--- a/net/base/escape.cc
+++ b/net/base/escape.cc
@@ -15,18 +15,6 @@
namespace {
-template <class char_type>
-inline char_type HexToInt(char_type ch) {
- if (ch >= '0' && ch <= '9')
- return ch - '0';
- if (ch >= 'A' && ch <= 'F')
- return ch - 'A' + 10;
- if (ch >= 'a' && ch <= 'f')
- return ch - 'a' + 10;
- NOTREACHED();
- return 0;
-}
-
static const char* const kHexString = "0123456789ABCDEF";
inline char IntToHex(int i) {
DCHECK(i >= 0 && i <= 15) << i << " not a hex value";
@@ -136,8 +124,8 @@ STR UnescapeURLImpl(const STR& escaped_text,
const typename STR::value_type least_sig_digit(
static_cast<typename STR::value_type>(escaped_text[i + 2]));
if (IsHexDigit(most_sig_digit) && IsHexDigit(least_sig_digit)) {
- unsigned char value = HexToInt(most_sig_digit) * 16 +
- HexToInt(least_sig_digit);
+ unsigned char value = HexDigitToInt(most_sig_digit) * 16 +
+ HexDigitToInt(least_sig_digit);
if (value >= 0x80 || // Unescape all high-bit characters.
// For 7-bit characters, the lookup table tells us all valid chars.
(kUrlUnescape[value] ||
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index e25eb50..1d903b8 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -186,12 +186,6 @@ STR GetSpecificHeaderT(const STR& headers, const STR& name) {
return ret;
}
-inline unsigned char HexToInt(unsigned char c) {
- DCHECK(IsHexDigit(c));
- static unsigned char kOffset[4] = {0, 0x30u, 0x37u, 0x57u};
- return c - kOffset[(c >> 5) & 3];
-}
-
// Similar to Base64Decode. Decodes a Q-encoded string to a sequence
// of bytes. If input is invalid, return false.
bool QPDecode(const std::string& input, std::string* output) {
@@ -207,7 +201,8 @@ bool QPDecode(const std::string& input, std::string* output) {
}
if (IsHexDigit(static_cast<unsigned char>(*(it + 1))) &&
IsHexDigit(static_cast<unsigned char>(*(it + 2)))) {
- unsigned char ch = HexToInt(*(it + 1)) * 16 + HexToInt(*(it + 2));
+ unsigned char ch = HexDigitToInt(*(it + 1)) * 16 +
+ HexDigitToInt(*(it + 2));
temp.push_back(static_cast<char>(ch));
++it;
++it;