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
Don't create temporary strings to escape DNSName labels #8013
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice shave!
size_t pos = 0; | ||
|
||
ret.reserve(len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this would be worth to keep reserve()
ing enough space to append the escaped label ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is covered by line 172. In the regular case that should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory we should have reserved enough space already at the beginning of DNSName::toString()
, but that might not be true due to escaping, I'll try to measure whether a ret.reserve(ret.size() + len)
helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is covered by line 172. In the regular case that should be enough.
Yes indeed, my bad.
size_t pos = 0; | ||
|
||
ret.reserve(len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is covered by line 172. In the regular case that should be enough.
Short description
Shaves a nice 20%+ off
DNSName::toString()
for regular names, and cut in half the CPU time when we encounter a 'special' character (not.
or\
and lesser or equal to0x20
or greater or equal to0x7f
).Checklist
I have: