Skip to content
Permalink
Browse files

urldata: convert bools to bitfields and move to end

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.
  • Loading branch information...
bagder committed Feb 25, 2019
1 parent 66637b4 commit 7e239f7d1d777b1283e7fc8b130d1343f0fb8c71
Showing with 234 additions and 260 deletions.
  1. +1 −2 lib/ftp.c
  2. +9 −5 lib/setopt.c
  3. +224 −253 lib/urldata.h
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -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! */
@@ -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:
@@ -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 */
@@ -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 */
@@ -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;

0 comments on commit 7e239f7

Please sign in to comment.
You can’t perform that action at this time.