@@ -319,21 +319,17 @@ fn buildWasmBinary(
319
319
try sendMessage (child .stdin .? , .update );
320
320
try sendMessage (child .stdin .? , .exit );
321
321
322
- const Header = std .zig .Server .Message .Header ;
323
322
var result : ? Cache.Path = null ;
324
323
var result_error_bundle = std .zig .ErrorBundle .empty ;
325
324
326
- const stdout = poller .fifo (.stdout );
325
+ const stdout = poller .reader (.stdout );
327
326
328
327
poll : while (true ) {
329
- while (stdout .readableLength () < @sizeOf (Header )) {
330
- if (! (try poller .poll ())) break :poll ;
331
- }
332
- const header = stdout .reader ().readStruct (Header ) catch unreachable ;
333
- while (stdout .readableLength () < header .bytes_len ) {
334
- if (! (try poller .poll ())) break :poll ;
335
- }
336
- const body = stdout .readableSliceOfLen (header .bytes_len );
328
+ const Header = std .zig .Server .Message .Header ;
329
+ while (stdout .buffered ().len < @sizeOf (Header )) if (! try poller .poll ()) break :poll ;
330
+ const header = stdout .takeStruct (Header , .little ) catch unreachable ;
331
+ while (stdout .buffered ().len < header .bytes_len ) if (! try poller .poll ()) break :poll ;
332
+ const body = stdout .take (header .bytes_len ) catch unreachable ;
337
333
338
334
switch (header .tag ) {
339
335
.zig_version = > {
@@ -373,15 +369,11 @@ fn buildWasmBinary(
373
369
},
374
370
else = > {}, // ignore other messages
375
371
}
376
-
377
- stdout .discard (body .len );
378
372
}
379
373
380
- const stderr = poller .fifo (.stderr );
381
- if (stderr .readableLength () > 0 ) {
382
- const owned_stderr = try stderr .toOwnedSlice ();
383
- defer gpa .free (owned_stderr );
384
- std .debug .print ("{s}" , .{owned_stderr });
374
+ const stderr = poller .reader (.stderr );
375
+ if (stderr .bufferedLen () > 0 ) {
376
+ std .debug .print ("{s}" , .{stderr .buffered ()});
385
377
}
386
378
387
379
// Send EOF to stdin.
0 commit comments