Skip to content

Commit

Permalink
avoid 1 allocation (per suggestion from Andrei)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Cao committed Feb 18, 2012
1 parent b801b26 commit 1c50ab9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion std/net/curl.d
Expand Up @@ -3339,7 +3339,9 @@ struct Curl

private string errorString(CurlCode code)
{
return format("%s on handle %s", to!string(curl_easy_strerror(code)), handle);
auto msgZ = curl_easy_strerror(code);
// doing the following (instead of just using std.conv.to!string) avoids 1 allocation
return format("%s on handle %s", cast(string) msgZ[0 .. core.stdc.strlen(msgZ)], handle);
}

private void throwOnStopped(string message = null)
Expand Down

0 comments on commit 1c50ab9

Please sign in to comment.