Skip to content

Commit 242da36

Browse files
committed
Remove excessive specialization of type_parser to improve compiler throughput.
1 parent e56e3d7 commit 242da36

File tree

1 file changed

+4
-47
lines changed

1 file changed

+4
-47
lines changed

Release/include/cpprest/streams.h

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,55 +1711,11 @@ class type_parser<CharType,char> : public _type_parser_base<CharType>
17111711
};
17121712

17131713
#ifdef _WIN32
1714-
template<>
1715-
class type_parser<char,std::basic_string<wchar_t>> : public _type_parser_base<char>
1714+
template<class CharType>
1715+
class type_parser<CharType, std::enable_if_t<sizeof(CharType) == 1, std::basic_string<wchar_t>>> : public _type_parser_base<CharType>
17161716
{
17171717
public:
1718-
static pplx::task<std::wstring> parse(streams::streambuf<char> buffer)
1719-
{
1720-
return _parse_input<std::basic_string<char>,std::basic_string<wchar_t>>(buffer, _accept_char, _extract_result);
1721-
}
1722-
1723-
private:
1724-
static bool _accept_char(const std::shared_ptr<std::basic_string<char>> &state, int_type ch)
1725-
{
1726-
if ( ch == concurrency::streams::char_traits<char>::eof() || isspace(ch)) return false;
1727-
state->push_back(char(ch));
1728-
return true;
1729-
}
1730-
static pplx::task<std::basic_string<wchar_t>> _extract_result(std::shared_ptr<std::basic_string<char>> state)
1731-
{
1732-
return pplx::task_from_result(utility::conversions::utf8_to_utf16(*state));
1733-
}
1734-
};
1735-
1736-
template<>
1737-
class type_parser<signed char,std::basic_string<wchar_t>> : public _type_parser_base<signed char>
1738-
{
1739-
public:
1740-
static pplx::task<std::wstring> parse(streams::streambuf<signed char> buffer)
1741-
{
1742-
return _parse_input<std::basic_string<char>,std::basic_string<wchar_t>>(buffer, _accept_char, _extract_result);
1743-
}
1744-
1745-
private:
1746-
static bool _accept_char(const std::shared_ptr<std::basic_string<char>> &state, int_type ch)
1747-
{
1748-
if ( ch == concurrency::streams::char_traits<char>::eof() || isspace(ch)) return false;
1749-
state->push_back(char(ch));
1750-
return true;
1751-
}
1752-
static pplx::task<std::basic_string<wchar_t>> _extract_result(std::shared_ptr<std::basic_string<char>> state)
1753-
{
1754-
return pplx::task_from_result(utility::conversions::utf8_to_utf16(*state));
1755-
}
1756-
};
1757-
1758-
template<>
1759-
class type_parser<unsigned char,std::basic_string<wchar_t>> : public _type_parser_base<unsigned char>
1760-
{
1761-
public:
1762-
static pplx::task<std::wstring> parse(streams::streambuf<unsigned char> buffer)
1718+
static pplx::task<std::wstring> parse(streams::streambuf<CharType> buffer)
17631719
{
17641720
return _parse_input<std::basic_string<char>,std::basic_string<wchar_t>>(buffer, _accept_char, _extract_result);
17651721
}
@@ -1781,3 +1737,4 @@ class type_parser<unsigned char,std::basic_string<wchar_t>> : public _type_parse
17811737
}}
17821738

17831739
#endif
1740+

0 commit comments

Comments
 (0)