From 873d3927c79e4127aa17cd41ffcf7210d69d4f0a Mon Sep 17 00:00:00 2001 From: ChUrl Date: Fri, 29 Jul 2022 14:35:42 +0200 Subject: [PATCH] replace char*/string with stringview --- c_os/user/devices/SerialOut.cc | 14 ++++---------- c_os/user/devices/SerialOut.h | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/c_os/user/devices/SerialOut.cc b/c_os/user/devices/SerialOut.cc index a858280..b4b29e2 100644 --- a/c_os/user/devices/SerialOut.cc +++ b/c_os/user/devices/SerialOut.cc @@ -40,14 +40,8 @@ void SerialOut::write(const char a) { com1.outb(a); } -void SerialOut::write(const char* a) { - const char* current = a; - do { - write(*current); - current = current + 1; - } while (*current != '\0'); -} - -void SerialOut::write(const bse::string& a) { - write(static_cast(a)); +void SerialOut::write(const bse::string_view a) { + for (char current : a) { + write(current); + } } diff --git a/c_os/user/devices/SerialOut.h b/c_os/user/devices/SerialOut.h index 822a296..8df4bb7 100644 --- a/c_os/user/devices/SerialOut.h +++ b/c_os/user/devices/SerialOut.h @@ -3,6 +3,7 @@ #include "kernel/IOport.h" #include "user/lib/String.h" +#include "user/lib/StringView.h" // NOTE: I took this code from https://wiki.osdev.org/Serial_Ports @@ -21,8 +22,7 @@ public: static char read(); static void write(char a); - static void write(const char* a); - static void write(const bse::string& a); + static void write(const bse::string_view a); }; #endif