summaryrefslogtreecommitdiff
path: root/lib/cookie.c
diff options
context:
space:
mode:
authorLauri Kasanen <cand@gmx.com>2018-03-30 18:33:52 +0300
committerDaniel Stenberg <daniel@haxx.se>2018-04-02 10:40:32 +0200
commit4073cd83b2f3bcf93f1ce7f5d567d22175bad9af (patch)
treeeeee27d641e37738414d87e7bf1a716734b9776a /lib/cookie.c
parent28faaacee287b019bcf2961da3bf2f91d331bcbd (diff)
downloadcurl-4073cd83b2f3bcf93f1ce7f5d567d22175bad9af.tar.gz
cookies: when reading from a file, only remove_expired once
This drops the cookie load time for 8k cookies from 178ms to 15ms. Closes #2441
Diffstat (limited to 'lib/cookie.c')
-rw-r--r--lib/cookie.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index 63deee163..1f932d78c 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -368,6 +368,7 @@ Curl_cookie_add(struct Curl_easy *data,
struct CookieInfo *c,
bool httpheader, /* TRUE if HTTP header-style line */
+ bool noexpire, /* if TRUE, skip remove_expired() */
char *lineptr, /* first character of the line */
const char *domain, /* default domain */
const char *path) /* full path used when this cookie is set,
@@ -819,7 +820,8 @@ Curl_cookie_add(struct Curl_easy *data,
the same domain and path as this */
/* at first, remove expired cookies */
- remove_expired(c);
+ if(!noexpire)
+ remove_expired(c);
#ifdef USE_LIBPSL
/* Check if the domain is a Public Suffix and if yes, ignore the cookie.
@@ -1026,9 +1028,10 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
while(*lineptr && ISBLANK(*lineptr))
lineptr++;
- Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL);
+ Curl_cookie_add(data, c, headerline, TRUE, lineptr, NULL, NULL);
}
free(line); /* free the line buffer */
+ remove_expired(c); /* run this once, not on every cookie */
if(fromfile)
fclose(fp);