Browse Source

Update fmt.odin

Fix hardcoded 64 bit, use assert instead of branched panic.
Jeroen van Rijn 2 years ago
parent
commit
030405dbb6
1 changed files with 3 additions and 7 deletions
  1. 3 7
      core/fmt/fmt.odin

+ 3 - 7
core/fmt/fmt.odin

@@ -53,7 +53,7 @@ User_Formatter :: #type proc(fi: ^Info, arg: any, verb: rune) -> bool
 // 	m := cast(^SomeType)arg.data
 // 	m := cast(^SomeType)arg.data
 // 	switch verb {
 // 	switch verb {
 // 	case 'v', 'd':
 // 	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:
 // 	case:
 // 		return false
 // 		return false
 // 	}
 // 	}
@@ -87,12 +87,8 @@ _user_formatters: ^map[typeid]User_Formatter
 // NOTE: Must be called before using register_user_formatter.
 // NOTE: Must be called before using register_user_formatter.
 //
 //
 set_user_formatters :: proc(m: ^map[typeid]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
 // Registers a user-defined formatter for a specific typeid
 //
 //