diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-07-15 16:31:59 +0000 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-07-18 13:02:34 +0200 |
| commit | 891ca8834122e55638d33a129baab7292b8ed6d0 (patch) | |
| tree | 2d8f3f1a6467d783fc0565e0dd2d433c31ff544b | |
| parent | a832505d9696ae66248b53602d41637bef4868aa (diff) | |
| download | teachos-891ca8834122e55638d33a129baab7292b8ed6d0.tar.xz teachos-891ca8834122e55638d33a129baab7292b8ed6d0.zip | |
kern: simplify print wrappers
| -rw-r--r-- | kern/src/print.cpp | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/kern/src/print.cpp b/kern/src/print.cpp index 64e2c65..2c8539b 100644 --- a/kern/src/print.cpp +++ b/kern/src/print.cpp @@ -7,43 +7,18 @@ namespace teachos { namespace { - print_handler * current_print_handler{}; - println_handler * current_println_handler{}; - print_handler * current_print_error_handler{}; - println_handler * current_println_error_handler{}; - } // namespace - - auto print(std::string_view text) -> void - { - if (current_print_handler) - { - current_print_handler(text); - } - } - - auto println(std::string_view text) -> void - { - if (current_println_handler) - { - current_println_handler(text); - } - } + constinit auto noop = [](std::string_view) {}; - auto print_error(std::string_view text) -> void - { - if (current_print_error_handler) - { - current_print_error_handler(text); - } - } + constinit auto current_print_handler = static_cast<print_handler *>(noop); + constinit auto current_println_handler = static_cast<println_handler *>(noop); + constinit auto current_print_error_handler = static_cast<print_handler *>(noop); + constinit auto current_println_error_handler = static_cast<println_handler *>(noop); + } // namespace - auto println_error(std::string_view text) -> void - { - if (current_println_error_handler) - { - current_println_error_handler(text); - } - } + auto print(std::string_view text) -> void { current_print_handler(text); } + auto println(std::string_view text) -> void { current_println_handler(text); } + auto print_error(std::string_view text) -> void { current_print_error_handler(text); } + auto println_error(std::string_view text) -> void { current_println_error_handler(text); } auto set_print_handler(print_handler handler) -> print_handler * { |
