Skip to content

Commit 2e8f8af

Browse files
authored
Base64DecoderWithIgnore.calcSizeUpperBound cannot return an error (#25834)
* std: Base64DecoderWithIgnore.calcSizeUpperBound cannot return an error * std: update doc comment of Base64DecoderWithIgnore.calcSizeUpperBound
1 parent 40132af commit 2e8f8af

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/std/base64.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ pub const Base64DecoderWithIgnore = struct {
313313
return result;
314314
}
315315

316-
/// Return the maximum possible decoded size for a given input length - The actual length may be less if the input includes padding.
317-
/// `InvalidPadding` is returned if the input length is not valid.
318-
pub fn calcSizeUpperBound(decoder_with_ignore: *const Base64DecoderWithIgnore, source_len: usize) Error!usize {
316+
/// Return the maximum possible decoded size for a given input length - The actual length may be
317+
/// less if the input includes padding or ignored characters.
318+
pub fn calcSizeUpperBound(decoder_with_ignore: *const Base64DecoderWithIgnore, source_len: usize) usize {
319319
var result = source_len / 4 * 3;
320320
if (decoder_with_ignore.decoder.pad_char == null) {
321321
const leftover = source_len % 4;
@@ -521,7 +521,7 @@ fn testAllApis(codecs: Codecs, expected_decoded: []const u8, expected_encoded: [
521521
{
522522
const decoder_ignore_nothing = codecs.decoderWithIgnore("");
523523
var buffer: [0x100]u8 = undefined;
524-
const decoded = buffer[0..try decoder_ignore_nothing.calcSizeUpperBound(expected_encoded.len)];
524+
const decoded = buffer[0..decoder_ignore_nothing.calcSizeUpperBound(expected_encoded.len)];
525525
const written = try decoder_ignore_nothing.decode(decoded, expected_encoded);
526526
try testing.expect(written <= decoded.len);
527527
try testing.expectEqualSlices(u8, expected_decoded, decoded[0..written]);
@@ -531,7 +531,7 @@ fn testAllApis(codecs: Codecs, expected_decoded: []const u8, expected_encoded: [
531531
fn testDecodeIgnoreSpace(codecs: Codecs, expected_decoded: []const u8, encoded: []const u8) !void {
532532
const decoder_ignore_space = codecs.decoderWithIgnore(" ");
533533
var buffer: [0x100]u8 = undefined;
534-
const decoded = buffer[0..try decoder_ignore_space.calcSizeUpperBound(encoded.len)];
534+
const decoded = buffer[0..decoder_ignore_space.calcSizeUpperBound(encoded.len)];
535535
const written = try decoder_ignore_space.decode(decoded, encoded);
536536
try testing.expectEqualSlices(u8, expected_decoded, decoded[0..written]);
537537
}

0 commit comments

Comments
 (0)