about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-25 12:35:11 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-25 12:48:30 +0200
commit3f0a183d48a44cbbe642842fb60b69cca9e83390 (patch)
tree0aad7dfeaa3a9265e030b2ed2739de4e042a69a2 /src/io
parentb6e5390ec286747ce6789f9cfec54dec8dc18fa3 (diff)
downloadchawan-3f0a183d48a44cbbe642842fb60b69cca9e83390.tar.gz
reduce new() usage
Diffstat (limited to 'src/io')
-rw-r--r--src/io/serialize.nim2
-rw-r--r--src/io/socketstream.nim15
2 files changed, 9 insertions, 8 deletions
diff --git a/src/io/serialize.nim b/src/io/serialize.nim
index 98f3a70a..1a7d0f62 100644
--- a/src/io/serialize.nim
+++ b/src/io/serialize.nim
@@ -309,7 +309,7 @@ proc sread*(stream: Stream, blob: var Blob) =
     stream.sread(file.path)
     blob = file
   else:
-    new(blob)
+    blob = Blob()
     stream.sread(blob.ctype)
     stream.sread(blob.size)
     let buffer = alloc(blob.size)
diff --git a/src/io/socketstream.nim b/src/io/socketstream.nim
index 2e56a4c7..29337a16 100644
--- a/src/io/socketstream.nim
+++ b/src/io/socketstream.nim
@@ -115,13 +115,14 @@ proc recvFileHandle*(s: SocketStream): FileHandle =
   dealloc(cmsgbuf)
 
 func newSocketStream*(): SocketStream =
-  new(result)
-  result.readDataImpl = cast[proc (s: Stream, buffer: pointer, bufLen: int): int
-      {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
-  ](sockReadData) # ... ???
-  result.writeDataImpl = sockWriteData
-  result.atEndImpl = sockAtEnd
-  result.closeImpl = sockClose
+  return SocketStream(
+    readDataImpl: cast[proc (s: Stream, buffer: pointer, bufLen: int): int
+        {.nimcall, raises: [Defect, IOError, OSError], tags: [ReadIOEffect], gcsafe.}
+    ](sockReadData), # ... ???
+    writeDataImpl: sockWriteData,
+    atEndImpl: sockAtEnd,
+    closeImpl: sockClose
+  )
 
 proc setBlocking*(ss: SocketStream, blocking: bool) =
   ss.source.getFd().setBlocking(blocking)