Skip to content

Commit

Permalink
Applying suggestions to encodeFromReaderToWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
Arwalk committed Aug 13, 2024
1 parent c0f372d commit b9dfe0f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/std/base64.zig
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ pub const Base64Encoder = struct {
// destWriter must be compatible with std.io.Writer's writeAll interface
// sourceReader must be compatible with std.io.Reader's read interface
pub fn encodeFromReaderToWriter(encoder: *const Base64Encoder, destWriter: anytype, sourceReader: anytype) !void {
var temp = [_]u8{0} ** 5;
var tempSource = [_]u8{0} ** 3;
while (true) {
var tempSource : [3]u8 = undefined;
const bytesRead = try sourceReader.read(&tempSource);
if (bytesRead == 0) {
break;
}

var temp: [5]u8 = undefined;
const s = encoder.encode(&temp, tempSource[0..bytesRead]);
try destWriter.writeAll(s);
}
Expand Down

0 comments on commit b9dfe0f

Please sign in to comment.