Skip to content

Commit

Permalink
urldata: convert bools to bitfields and move to end
Browse files Browse the repository at this point in the history
This allows the compiler to pack and align the structs better in
memory. For a rather feature-complete build on x86_64 Linux, gcc 8.1.2
makes the Curl_easy struct 4.9% smaller. From 6312 bytes to 6000.

Removed an unused struct field.

No functionality changes.

Closes #3610
  • Loading branch information
bagder committed Feb 27, 2019
1 parent 50482b8 commit 62a2534
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 261 deletions.
2 changes: 1 addition & 1 deletion lib/connect.c
Expand Up @@ -1434,7 +1434,7 @@ void Curl_conncontrol(struct connectdata *conn,
if((ctrl == CONNCTRL_STREAM) &&
(conn->handler->flags & PROTOPT_STREAM))
DEBUGF(infof(conn->data, "Kill stream: %s\n", reason));
else if(closeit != conn->bits.close) {
else if((bit)closeit != conn->bits.close) {
DEBUGF(infof(conn->data, "Marked for [%s]: %s\n",
closeit?"closure":"keep alive", reason));
conn->bits.close = closeit; /* the only place in the source code that
Expand Down
1 change: 0 additions & 1 deletion lib/ftp.c
Expand Up @@ -4395,7 +4395,6 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
return CURLE_OUT_OF_MEMORY;

ftp->path = &data->state.up.path[1]; /* don't include the initial slash */
data->state.slash_removed = TRUE; /* we've skipped the slash */

/* FTP URLs support an extension like ";type=<typecode>" that
* we'll try to get now! */
Expand Down
2 changes: 1 addition & 1 deletion lib/http.c
Expand Up @@ -751,7 +751,7 @@ Curl_http_output_auth(struct connectdata *conn,
#ifndef CURL_DISABLE_PROXY
/* Send proxy authentication header if needed */
if(conn->bits.httpproxy &&
(conn->bits.tunnel_proxy == proxytunnel)) {
(conn->bits.tunnel_proxy == (bit)proxytunnel)) {
result = output_auth_headers(conn, authproxy, request, path, TRUE);
if(result)
return result;
Expand Down
14 changes: 9 additions & 5 deletions lib/setopt.c
Expand Up @@ -682,7 +682,7 @@ static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,
* Set header option.
*/
arg = va_arg(param, long);
data->set.sep_headers = (arg & CURLHEADER_SEPARATE)? TRUE: FALSE;
data->set.sep_headers = (bool)((arg & CURLHEADER_SEPARATE)? TRUE: FALSE);
break;

case CURLOPT_HTTP200ALIASES:
Expand Down Expand Up @@ -884,7 +884,8 @@ static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,

/* the DIGEST_IE bit is only used to set a special marker, for all the
rest we need to handle it as normal DIGEST */
data->state.authhost.iestyle = (auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE;
data->state.authhost.iestyle =
(bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE);

if(auth & CURLAUTH_DIGEST_IE) {
auth |= CURLAUTH_DIGEST; /* set standard digest bit */
Expand Down Expand Up @@ -967,7 +968,8 @@ static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,

/* the DIGEST_IE bit is only used to set a special marker, for all the
rest we need to handle it as normal DIGEST */
data->state.authproxy.iestyle = (auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE;
data->state.authproxy.iestyle =
(bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE);

if(auth & CURLAUTH_DIGEST_IE) {
auth |= CURLAUTH_DIGEST; /* set standard digest bit */
Expand Down Expand Up @@ -2076,13 +2078,15 @@ static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,

case CURLOPT_SSL_OPTIONS:
arg = va_arg(param, long);
data->set.ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
data->set.ssl.enable_beast =
(bool)((arg&CURLSSLOPT_ALLOW_BEAST) ? TRUE : FALSE);
data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
break;

case CURLOPT_PROXY_SSL_OPTIONS:
arg = va_arg(param, long);
data->set.proxy_ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
data->set.proxy_ssl.enable_beast =
(bool)((arg&CURLSSLOPT_ALLOW_BEAST) ? TRUE : FALSE);
data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
break;

Expand Down

0 comments on commit 62a2534

Please sign in to comment.