From 3f0a183d48a44cbbe642842fb60b69cca9e83390 Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 25 Oct 2023 12:35:11 +0200 Subject: reduce new() usage --- src/types/cookie.nim | 7 ++++--- src/types/url.nim | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/types') diff --git a/src/types/cookie.nim b/src/types/cookie.nim index 627975ab..872e97dd 100644 --- a/src/types/cookie.nim +++ b/src/types/cookie.nim @@ -207,9 +207,10 @@ proc serialize*(cookiejar: CookieJar, url: URL): string = proc newCookie*(str: string, url: URL = nil): JSResult[Cookie] {.jsctor.} = - let cookie = new(Cookie) - cookie.expires = -1 - cookie.created = now().toTime().toUnix() + let cookie = Cookie( + expires: -1, + created: now().toTime().toUnix() + ) var first = true var haspath = false var hasdomain = false diff --git a/src/types/url.nim b/src/types/url.nim index 1ded3d36..69a3a78e 100644 --- a/src/types/url.nim +++ b/src/types/url.nim @@ -849,7 +849,7 @@ proc cloneInto(a, b: URL) = b.searchParams.url = some(b) proc newURL*(url: URL): URL = - new(result) + result = URL() url.cloneInto(result) proc setHref(url: URL, s: string): Err[JSError] {.jsfset: "href".} = @@ -905,7 +905,7 @@ proc newURLSearchParams[ Table[string, string]| string ](init: T = ""): URLSearchParams {.jsctor.} = - new(result) + result = URLSearchParams() when T is seq[(string, string)]: result.list = init elif T is Table[string, string]: -- cgit 1.4.1-2-gfad0