From 485355274e1d40445e6c635a382297cd6b2e5e0d Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 2 Feb 2018 20:25:19 +0100 Subject: [PATCH] Optimized the MarlinSerial class by declaring all methods static. The MarlinSerial defines no member variable, though the AVR GCC stored a "this" pointer onto stack when calling the non-static methods anyway. --- Firmware/MarlinSerial.cpp | 7 ----- Firmware/MarlinSerial.h | 65 +++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 40 deletions(-) diff --git a/Firmware/MarlinSerial.cpp b/Firmware/MarlinSerial.cpp index 0464fe41f..02903a776 100644 --- a/Firmware/MarlinSerial.cpp +++ b/Firmware/MarlinSerial.cpp @@ -99,13 +99,6 @@ ISR(USART1_RX_vect) #endif #endif -// Constructors //////////////////////////////////////////////////////////////// - -MarlinSerial::MarlinSerial() -{ - -} - // Public Methods ////////////////////////////////////////////////////////////// void MarlinSerial::begin(long baud) diff --git a/Firmware/MarlinSerial.h b/Firmware/MarlinSerial.h index d23b69f09..5c2245df9 100644 --- a/Firmware/MarlinSerial.h +++ b/Firmware/MarlinSerial.h @@ -90,14 +90,13 @@ class MarlinSerial //: public Stream { public: - MarlinSerial(); - void begin(long); - void end(); - int peek(void); - int read(void); - void flush(void); + static void begin(long); + static void end(); + static int peek(void); + static int read(void); + static void flush(void); - FORCE_INLINE int available(void) + static FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } @@ -110,7 +109,7 @@ class MarlinSerial //: public Stream M_UDRx = c; } */ - void write(uint8_t c) + static void write(uint8_t c) { if (selectedSerialPort == 0) { @@ -124,7 +123,7 @@ class MarlinSerial //: public Stream } } - void checkRx(void) + static void checkRx(void) { if (selectedSerialPort == 0) { if((M_UCSRxA & (1<