[haiku] [PATCH 1/2] Optimize the serial_puts function to use directly EFI API

  • From: Louis Feuvrier <manny@xxxxxxxxxxxx>
  • To: haiku@xxxxxxxxxxxxx
  • Date: Fri, 21 Mar 2014 15:59:34 +0100

From: Louis Feuvrier <louis@xxxxxxxxxxxx>

This change removes the validity of the \n alone character as a newline. The
user must specify both \r and \n in order for the console to jump to a new
line and return carriage. However, the function is not called for each and
every character, thus increasing the performances.
---
 src/system/boot/platform/efi/serial.cpp | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/system/boot/platform/efi/serial.cpp 
b/src/system/boot/platform/efi/serial.cpp
index 7f30711..b6ddd74 100644
--- a/src/system/boot/platform/efi/serial.cpp
+++ b/src/system/boot/platform/efi/serial.cpp
@@ -42,18 +42,9 @@ serial_puts(const char* string, size_t size)
        if (sSerialEnabled <= 0 || sSerial == NULL)
                return;
 
-       //TODO: We can write strings instead of char by char.
-       while (size-- != 0) {
-               char c = string[0];
-
-               if (c == '\n') {
-                       serial_putc('\r');
-                       serial_putc('\n');
-               } else if (c != '\r')
-                       serial_putc(c);
-
-               string++;
-       }
+       // TODO: \r\n is not handled, but the string printing makes sense now
+       // The (char*) cast is equivalent to the previous calls to serial_putc
+       sSerial->Write(sSerial, &size, (char*)string);
 }
 
 
-- 
1.9.0


Other related posts:

  • » [haiku] [PATCH 1/2] Optimize the serial_puts function to use directly EFI API - Louis Feuvrier