Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conncache: make hashkey avoid malloc #1365

Closed
wants to merge 1 commit into from
Closed

Conversation

bagder
Copy link
Member

@bagder bagder commented Mar 28, 2017

... to make it much faster. Idea developed with primepie on IRC.

... to make it much faster. Idea developed with primepie on IRC.
@mention-bot
Copy link

@bagder, thanks for your PR! By analyzing the history of the files in this pull request, we identified @yangtse, @linusnielsen and @mkauf to be potential reviewers.

DEBUGASSERT(len > 32);

/* put the number first so that the hostname gets cut off if too long */
snprintf(buf, len, "%ld%s", conn->port, hostname);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't snprintf C99? I believe MSVC versions prior to 2015 only have a _snprintf that doesn't append a '\0' if the string gets truncated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one of the reasons why have our own set of *printf() implementations and snprintf comes from here: https://github.com/curl/curl/blob/master/lib/curlx.h#L105

If you check the code closer you'll see that we already use snprintf() in numerous places thanks to this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great! I forgot about that.

Copy link
Member

@MarcelRaad MarcelRaad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@@ -128,7 +128,8 @@ void Curl_conncache_destroy(struct conncache *connc)
}

/* returns an allocated key to find a bundle for this connection */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix the comment too.

@bagder bagder closed this in 2066072 Mar 28, 2017
@bagder
Copy link
Member Author

bagder commented Mar 28, 2017

thanks for the review!

@bagder bagder deleted the bagder/improve-hashkey branch March 29, 2017 08:14
@lock lock bot locked as resolved and limited conversation to collaborators May 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants