authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2019-08-19 22:28:13+12:00
committergravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2019-08-19 22:28:13+12:00
loge0447c6ddd71d400fc501bf33c4cb33dde4e3300
tree5dcc5766d590588a7ce86b89fab71e1bd4535110
parent98859c885e8e66518c1081c56d203cdd77c51ce8

std/fmt: Make FormatOptions arguments non-comptime

No need and should help avoid exessive function monomorphizaton.

2 files changed, 18 insertions(+), 18 deletions(-)

std/fmt.zig+17-17
...@@ -276,7 +276,7 @@ pub fn format(...@@ -276,7 +276,7 @@ pub fn format(
276pub fn formatType(276pub fn formatType(
277 value: var,277 value: var,
278 comptime fmt: []const u8,278 comptime fmt: []const u8,
279 comptime options: FormatOptions,279 options: FormatOptions,
280 context: var,280 context: var,
281 comptime Errors: type,281 comptime Errors: type,
282 output: fn (@typeOf(context), []const u8) Errors!void,282 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -428,7 +428,7 @@ pub fn formatType(...@@ -428,7 +428,7 @@ pub fn formatType(
428fn formatValue(428fn formatValue(
429 value: var,429 value: var,
430 comptime fmt: []const u8,430 comptime fmt: []const u8,
431 comptime options: FormatOptions,431 options: FormatOptions,
432 context: var,432 context: var,
433 comptime Errors: type,433 comptime Errors: type,
434 output: fn (@typeOf(context), []const u8) Errors!void,434 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -450,7 +450,7 @@ fn formatValue(...@@ -450,7 +450,7 @@ fn formatValue(
450pub fn formatIntValue(450pub fn formatIntValue(
451 value: var,451 value: var,
452 comptime fmt: []const u8,452 comptime fmt: []const u8,
453 comptime options: FormatOptions,453 options: FormatOptions,
454 context: var,454 context: var,
455 comptime Errors: type,455 comptime Errors: type,
456 output: fn (@typeOf(context), []const u8) Errors!void,456 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -492,7 +492,7 @@ pub fn formatIntValue(...@@ -492,7 +492,7 @@ pub fn formatIntValue(
492fn formatFloatValue(492fn formatFloatValue(
493 value: var,493 value: var,
494 comptime fmt: []const u8,494 comptime fmt: []const u8,
495 comptime options: FormatOptions,495 options: FormatOptions,
496 context: var,496 context: var,
497 comptime Errors: type,497 comptime Errors: type,
498 output: fn (@typeOf(context), []const u8) Errors!void,498 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -509,7 +509,7 @@ fn formatFloatValue(...@@ -509,7 +509,7 @@ fn formatFloatValue(
509pub fn formatText(509pub fn formatText(
510 bytes: []const u8,510 bytes: []const u8,
511 comptime fmt: []const u8,511 comptime fmt: []const u8,
512 comptime options: FormatOptions,512 options: FormatOptions,
513 context: var,513 context: var,
514 comptime Errors: type,514 comptime Errors: type,
515 output: fn (@typeOf(context), []const u8) Errors!void,515 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -530,7 +530,7 @@ pub fn formatText(...@@ -530,7 +530,7 @@ pub fn formatText(
530530
531pub fn formatAsciiChar(531pub fn formatAsciiChar(
532 c: u8,532 c: u8,
533 comptime options: FormatOptions,533 options: FormatOptions,
534 context: var,534 context: var,
535 comptime Errors: type,535 comptime Errors: type,
536 output: fn (@typeOf(context), []const u8) Errors!void,536 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -540,7 +540,7 @@ pub fn formatAsciiChar(...@@ -540,7 +540,7 @@ pub fn formatAsciiChar(
540540
541pub fn formatBuf(541pub fn formatBuf(
542 buf: []const u8,542 buf: []const u8,
543 comptime options: FormatOptions,543 options: FormatOptions,
544 context: var,544 context: var,
545 comptime Errors: type,545 comptime Errors: type,
546 output: fn (@typeOf(context), []const u8) Errors!void,546 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -560,7 +560,7 @@ pub fn formatBuf(...@@ -560,7 +560,7 @@ pub fn formatBuf(
560// same type unambiguously.560// same type unambiguously.
561pub fn formatFloatScientific(561pub fn formatFloatScientific(
562 value: var,562 value: var,
563 comptime options: FormatOptions,563 options: FormatOptions,
564 context: var,564 context: var,
565 comptime Errors: type,565 comptime Errors: type,
566 output: fn (@typeOf(context), []const u8) Errors!void,566 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -655,7 +655,7 @@ pub fn formatFloatScientific(...@@ -655,7 +655,7 @@ pub fn formatFloatScientific(
655// By default floats are printed at full precision (no rounding).655// By default floats are printed at full precision (no rounding).
656pub fn formatFloatDecimal(656pub fn formatFloatDecimal(
657 value: var,657 value: var,
658 comptime options: FormatOptions,658 options: FormatOptions,
659 context: var,659 context: var,
660 comptime Errors: type,660 comptime Errors: type,
661 output: fn (@typeOf(context), []const u8) Errors!void,661 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -800,7 +800,7 @@ pub fn formatFloatDecimal(...@@ -800,7 +800,7 @@ pub fn formatFloatDecimal(
800800
801pub fn formatBytes(801pub fn formatBytes(
802 value: var,802 value: var,
803 comptime options: FormatOptions,803 options: FormatOptions,
804 comptime radix: usize,804 comptime radix: usize,
805 context: var,805 context: var,
806 comptime Errors: type,806 comptime Errors: type,
...@@ -842,7 +842,7 @@ pub fn formatInt(...@@ -842,7 +842,7 @@ pub fn formatInt(
842 value: var,842 value: var,
843 base: u8,843 base: u8,
844 uppercase: bool,844 uppercase: bool,
845 comptime options: FormatOptions,845 options: FormatOptions,
846 context: var,846 context: var,
847 comptime Errors: type,847 comptime Errors: type,
848 output: fn (@typeOf(context), []const u8) Errors!void,848 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -864,7 +864,7 @@ fn formatIntSigned(...@@ -864,7 +864,7 @@ fn formatIntSigned(
864 value: var,864 value: var,
865 base: u8,865 base: u8,
866 uppercase: bool,866 uppercase: bool,
867 comptime options: FormatOptions,867 options: FormatOptions,
868 context: var,868 context: var,
869 comptime Errors: type,869 comptime Errors: type,
870 output: fn (@typeOf(context), []const u8) Errors!void,870 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -895,7 +895,7 @@ fn formatIntUnsigned(...@@ -895,7 +895,7 @@ fn formatIntUnsigned(
895 value: var,895 value: var,
896 base: u8,896 base: u8,
897 uppercase: bool,897 uppercase: bool,
898 comptime options: FormatOptions,898 options: FormatOptions,
899 context: var,899 context: var,
900 comptime Errors: type,900 comptime Errors: type,
901 output: fn (@typeOf(context), []const u8) Errors!void,901 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -936,7 +936,7 @@ fn formatIntUnsigned(...@@ -936,7 +936,7 @@ fn formatIntUnsigned(
936 }936 }
937}937}
938938
939pub fn formatIntBuf(out_buf: []u8, value: var, base: u8, uppercase: bool, comptime options: FormatOptions) usize {939pub fn formatIntBuf(out_buf: []u8, value: var, base: u8, uppercase: bool, options: FormatOptions) usize {
940 var context = FormatIntBuf{940 var context = FormatIntBuf{
941 .out_buf = out_buf,941 .out_buf = out_buf,
942 .index = 0,942 .index = 0,
...@@ -1099,7 +1099,7 @@ test "bufPrintInt" {...@@ -1099,7 +1099,7 @@ test "bufPrintInt" {
1099 testing.expect(mem.eql(u8, bufPrintIntToSlice(buf, i32(-42), 10, false, FormatOptions{ .width = 3 }), "-42"));1099 testing.expect(mem.eql(u8, bufPrintIntToSlice(buf, i32(-42), 10, false, FormatOptions{ .width = 3 }), "-42"));
1100}1100}
11011101
1102fn bufPrintIntToSlice(buf: []u8, value: var, base: u8, uppercase: bool, comptime options: FormatOptions) []u8 {1102fn bufPrintIntToSlice(buf: []u8, value: var, base: u8, uppercase: bool, options: FormatOptions) []u8 {
1103 return buf[0..formatIntBuf(buf, value, base, uppercase, options)];1103 return buf[0..formatIntBuf(buf, value, base, uppercase, options)];
1104}1104}
11051105
...@@ -1339,7 +1339,7 @@ test "custom" {...@@ -1339,7 +1339,7 @@ test "custom" {
1339 pub fn format(1339 pub fn format(
1340 self: SelfType,1340 self: SelfType,
1341 comptime fmt: []const u8,1341 comptime fmt: []const u8,
1342 comptime options: FormatOptions,1342 options: FormatOptions,
1343 context: var,1343 context: var,
1344 comptime Errors: type,1344 comptime Errors: type,
1345 output: fn (@typeOf(context), []const u8) Errors!void,1345 output: fn (@typeOf(context), []const u8) Errors!void,
...@@ -1545,7 +1545,7 @@ test "formatType max_depth" {...@@ -1545,7 +1545,7 @@ test "formatType max_depth" {
1545 pub fn format(1545 pub fn format(
1546 self: SelfType,1546 self: SelfType,
1547 comptime fmt: []const u8,1547 comptime fmt: []const u8,
1548 comptime options: FormatOptions,1548 options: FormatOptions,
1549 context: var,1549 context: var,
1550 comptime Errors: type,1550 comptime Errors: type,
1551 output: fn (@typeOf(context), []const u8) Errors!void,1551 output: fn (@typeOf(context), []const u8) Errors!void,
std/math/big/int.zig+1-1
...@@ -519,7 +519,7 @@ pub const Int = struct {...@@ -519,7 +519,7 @@ pub const Int = struct {
519 pub fn format(519 pub fn format(
520 self: Int,520 self: Int,
521 comptime fmt: []const u8,521 comptime fmt: []const u8,
522 comptime options: std.fmt.FormatOptions,522 options: std.fmt.FormatOptions,
523 context: var,523 context: var,
524 comptime FmtError: type,524 comptime FmtError: type,
525 output: fn (@typeOf(context), []const u8) FmtError!void,525 output: fn (@typeOf(context), []const u8) FmtError!void,