Skip to content

cookie: overhaul and cleanup - #15247

Closed
bagder wants to merge 4 commits into
masterfrom
bagder/cookie-split
Closed

cookie: overhaul and cleanup#15247
bagder wants to merge 4 commits into
masterfrom
bagder/cookie-split

Conversation

@bagder

@bagder bagder commented Oct 10, 2024

Copy link
Copy Markdown
Member
  • split the huge Curl_cookie_add() into several smaller static functions

  • switch to using the common llist instead of custom linked list

  • use less memory for *getlist()

  • use bitfields for flags in the Cookie struct

- split the huge Curl_cookie_add() into several smaller static functions

- switch to using the common llist instead of custom linked list

- use less memory for *getlist()

- use bitfields for flags in the Cookie struct
@bagder

bagder commented Oct 10, 2024

Copy link
Copy Markdown
Member Author

McCabe cyclomatic complexity on cookie.c

Top-10 with this PR applied

81      83      142     472     324     lib/cookie.c(473): parse_cookie_header
34      34      47      979     103     lib/cookie.c(980): replace_existing
27      33      75      797     133     lib/cookie.c(798): parse_netscape
23      23      44      1093    100     lib/cookie.c(1094): Curl_cookie_add
20      20      43      1348    98      lib/cookie.c(1348): Curl_cookie_getlist
16      16      58      1552    95      lib/cookie.c(1552): cookie_output
15      15      41      1209    75      lib/cookie.c(1209): Curl_cookie_init
14      14      26      1293    30      lib/cookie.c(1293): cookie_sort
11      11      34      143     70      lib/cookie.c(143): pathmatch
10      10      8       1518    25      lib/cookie.c(1518): get_netscape_format

Top-10 in master (without this PR)

175     183     350     483     712     lib/cookie.c(484): Curl_cookie_add
21      21      48      1378    110     lib/cookie.c(1378): Curl_cookie_getlist
16      16      57      1618    92      lib/cookie.c(1618): cookie_output
14      14      38      1211    73      lib/cookie.c(1211): Curl_cookie_init
14      14      26      1293    30      lib/cookie.c(1293): cookie_sort
11      11      34      156     70      lib/cookie.c(156): pathmatch
10      10      8       1584    25      lib/cookie.c(1584): get_netscape_format
10      10      23      381     48      lib/cookie.c(381): remove_expired
8       8       26      1711    32      lib/cookie.c(1711): cookie_list
8       8       24      1526    35      lib/cookie.c(1526): Curl_cookie_clearsess

@bagder bagder closed this in be39ed1 Oct 11, 2024
@bagder
bagder deleted the bagder/cookie-split branch October 11, 2024 07:01
pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
- split the huge Curl_cookie_add() into several smaller static functions

- switch to using the common llist instead of custom linked list

- use less memory for *getlist()

- use bitfields for flags in the Cookie struct

- avoid the copy for date parsing

- more consistent variable naming

Closes curl#15247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant