zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 34644511bb6d83aa6575641ef79e5eefb495e3e1 (tree)
parent d4c85079c5796805e6f44cadaee618468267db63
Author: rpkak <rpkak@users.noreply.github.com>
Date:   Mon,  6 Jan 2025 12:06:52 +0100

std.fmt: remove placeholders from binary

Diffstat:
Mlib/std/fmt.zig | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig @@ -99,7 +99,8 @@ pub fn format( @setEvalBranchQuota(2000000); comptime var arg_state: ArgState = .{ .args_len = fields_info.len }; comptime var i = 0; - inline while (i < fmt.len) { + comptime var literal: []const u8 = ""; + inline while (true) { const start_index = i; inline while (i < fmt.len) : (i += 1) { @@ -121,14 +122,17 @@ pub fn format( i += 2; } - // Write out the literal - if (start_index != end_index) { - try writer.writeAll(fmt[start_index..end_index]); - } + literal = literal ++ fmt[start_index..end_index]; // We've already skipped the other brace, restart the loop if (unescape_brace) continue; + // Write out the literal + if (literal.len != 0) { + try writer.writeAll(literal); + literal = ""; + } + if (i >= fmt.len) break; if (fmt[i] == '}') {