mirror of
https://github.com/jetzig-framework/jetzig.git
synced 2025-05-14 22:16:08 +00:00
Removed unnecessary allocation
This commit is contained in:
parent
5a6ea71ab9
commit
02fd62b415
@ -22,11 +22,14 @@ pub const CookieOptions = struct {
|
|||||||
|
|
||||||
/// Builds a cookie string
|
/// Builds a cookie string
|
||||||
pub fn allocPrint(self: CookieOptions, allocator: std.mem.Allocator, cookie_name: []const u8, cookie_value: []const u8) ![]const u8 {
|
pub fn allocPrint(self: CookieOptions, allocator: std.mem.Allocator, cookie_name: []const u8, cookie_value: []const u8) ![]const u8 {
|
||||||
var cookie_string = std.ArrayList(u8).init(allocator);
|
|
||||||
// add cookie name, cookie value, path, and domain regardless of cookie options
|
// add cookie name, cookie value, path, and domain regardless of cookie options
|
||||||
const standard_components = try std.fmt.allocPrint(allocator, "{s}={s}; path={s}; domain={s};", .{ cookie_name, cookie_value, self.path, self.domain });
|
const standard_components = try std.fmt.allocPrint(allocator, "{s}={s}; path={s}; domain={s};", .{
|
||||||
defer allocator.free(standard_components);
|
cookie_name,
|
||||||
try cookie_string.appendSlice(standard_components);
|
cookie_value,
|
||||||
|
self.path,
|
||||||
|
self.domain,
|
||||||
|
});
|
||||||
|
var cookie_string = std.ArrayList(u8).fromOwnedSlice(allocator, standard_components);
|
||||||
// secure is required if samesite is set to none
|
// secure is required if samesite is set to none
|
||||||
var require_secure = false;
|
var require_secure = false;
|
||||||
var buf: [256]u8 = undefined;
|
var buf: [256]u8 = undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user