From 030405dbb6f4ac53cd2063e8598433044cc3fe3e Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Mon, 27 Mar 2023 11:06:29 +0200 Subject: [PATCH] Update fmt.odin Fix hardcoded 64 bit, use assert instead of branched panic. --- core/fmt/fmt.odin | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index f79c5b39f..3cd655eaf 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -53,7 +53,7 @@ User_Formatter :: #type proc(fi: ^Info, arg: any, verb: rune) -> bool // m := cast(^SomeType)arg.data // switch verb { // case 'v', 'd': -// fmt.fmt_int(fi, u64(m.value), true, 64, verb) +// fmt.fmt_int(fi, u64(m.value), true, 8 * size_of(SomeType), verb) // case: // return false // } @@ -87,12 +87,8 @@ _user_formatters: ^map[typeid]User_Formatter // NOTE: Must be called before using register_user_formatter. // set_user_formatters :: proc(m: ^map[typeid]User_Formatter) { - if _user_formatters==nil { - _user_formatters = m - } - else { - panic("set_user_formatters must not be called more than once.") - } + assert(_user_formatters == nil, "set_user_formatters must not be called more than once.") + _user_formatters = m } // Registers a user-defined formatter for a specific typeid //