-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Minor optimisations #454
Minor optimisations #454
Conversation
let string = try self.encode(value) | ||
var buffer = context.allocator.buffer(capacity: string.utf8.count) |
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.
Why not create the buffer from the string using NIO's helpers?
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.
No because that uses a temporary allocator and not the one that was attached to the Channel
let data = try self.encode(value) | ||
var buffer = context.allocator.buffer(capacity: data.count) |
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.
Can we use NIO's allocator helpers here
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.
No because that uses a temporary allocator and not the one that was attached to the Channel
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.
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.
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.
Fair point. Will fix
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 don't mind merging this as-is. But it seems sensible to me to merge the call to allocate and write into one.
Co-authored-by: Joannis Orlandos <[email protected]>
Don't allocate ByteBuffer before we know its size.
Provide contentLength when generating responses so header field size is not recalculated, when contentLength is added
Use
HTTPFields.contains
instead of subscript which constructs contents of HTTPField