Browse Source

Use C's const char* for status strings rather than C++'s std::string, which is slower

miguelfreitas
David Joel Schwartz 14 years ago committed by Luke Dashjr
parent
commit
ae81b82fb8
  1. 15
      src/bitcoinrpc.cpp

15
src/bitcoinrpc.cpp

@ -1931,12 +1931,13 @@ static string HTTPReply(int nStatus, const string& strMsg)
"</HEAD>\r\n" "</HEAD>\r\n"
"<BODY><H1>401 Unauthorized.</H1></BODY>\r\n" "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n"
"</HTML>\r\n", rfc1123Time().c_str(), FormatFullVersion().c_str()); "</HTML>\r\n", rfc1123Time().c_str(), FormatFullVersion().c_str());
string strStatus; const char *cStatus;
if (nStatus == 200) strStatus = "OK"; if (nStatus == 200) cStatus = "OK";
else if (nStatus == 400) strStatus = "Bad Request"; else if (nStatus == 400) cStatus = "Bad Request";
else if (nStatus == 403) strStatus = "Forbidden"; else if (nStatus == 403) cStatus = "Forbidden";
else if (nStatus == 404) strStatus = "Not Found"; else if (nStatus == 404) cStatus = "Not Found";
else if (nStatus == 500) strStatus = "Internal Server Error"; else if (nStatus == 500) cStatus = "Internal Server Error";
else cStatus = "";
return strprintf( return strprintf(
"HTTP/1.1 %d %s\r\n" "HTTP/1.1 %d %s\r\n"
"Date: %s\r\n" "Date: %s\r\n"
@ -1947,7 +1948,7 @@ static string HTTPReply(int nStatus, const string& strMsg)
"\r\n" "\r\n"
"%s", "%s",
nStatus, nStatus,
strStatus.c_str(), cStatus,
rfc1123Time().c_str(), rfc1123Time().c_str(),
strMsg.size(), strMsg.size(),
FormatFullVersion().c_str(), FormatFullVersion().c_str(),

Loading…
Cancel
Save