diff options
author | bptato <nincsnevem662@gmail.com> | 2023-10-25 12:35:11 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-10-25 12:48:30 +0200 |
commit | 3f0a183d48a44cbbe642842fb60b69cca9e83390 (patch) | |
tree | 0aad7dfeaa3a9265e030b2ed2739de4e042a69a2 /src/types | |
parent | b6e5390ec286747ce6789f9cfec54dec8dc18fa3 (diff) | |
download | chawan-3f0a183d48a44cbbe642842fb60b69cca9e83390.tar.gz |
reduce new() usage
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/cookie.nim | 7 | ||||
-rw-r--r-- | src/types/url.nim | 4 |
2 files changed, 6 insertions, 5 deletions
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]: |