mirror of
https://github.com/curl/curl.git
synced 2026-08-25 06:03:32 +03:00
urlapi: leaner with fewer allocs
Slightly faster with more robust code. Uses fewer and smaller mallocs. - remove two fields from the URL handle struct - reduce copies and allocs - use dynbuf buffers more instead of custom malloc + copies - uses dynbuf to build the host name in reduces serial alloc+free within the same function. - move dedotdotify into urlapi.c and make it static, not strdup the input and optimize it by checking for . and / before using strncmp - remove a few strlen() calls - add Curl_dyn_setlen() that can "trim" an existing dynbuf Closes #9408
This commit is contained in:
parent
2ae81e680b
commit
f703cf971c
11 changed files with 565 additions and 596 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#define Curl_dyn_len(a) curlx_dyn_len(a)
|
||||
#define Curl_dyn_reset(a) curlx_dyn_reset(a)
|
||||
#define Curl_dyn_tail(a,b) curlx_dyn_tail(a,b)
|
||||
#define Curl_dyn_setlen(a,b) curlx_dyn_setlen(a,b)
|
||||
#define curlx_dynbuf dynbuf /* for the struct name */
|
||||
#endif
|
||||
|
||||
|
|
@ -63,6 +64,7 @@ CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
|
|||
WARN_UNUSED_RESULT;
|
||||
void Curl_dyn_reset(struct dynbuf *s);
|
||||
CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail);
|
||||
CURLcode Curl_dyn_setlen(struct dynbuf *s, size_t set);
|
||||
char *Curl_dyn_ptr(const struct dynbuf *s);
|
||||
unsigned char *Curl_dyn_uptr(const struct dynbuf *s);
|
||||
size_t Curl_dyn_len(const struct dynbuf *s);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue