Open xcvista opened 8 years ago
Does this impact performance?
@PaulStoffregen I believe the impact is minimal (and you can make most functions inline.) However this does result in much cleaner code and clears up some code smell.
As written, this appears to add function calls within the timing-sensitive Serial interrupt.
You're asking maintainers of a successful open source project used by millions of people to change timing-critical code in what is probably the most important part of the core library, and the best answer you have for performance is "believe the impact is minimal".
This sort of change needs to be very carefully tested and its performance impact well known. Successful projects with huge user bases don't go about changing their most important code with little or no testing only because someone doesn't like the coding style.
@PaulStoffregen You could have also used things like macros and non-virtual inline methods. The resulting assembler code, especially when using macros, will be absolutely identical to the current code, yet it improves readability.
I am attempting this code in a new core I am writing for another board (based on STM32F103CB @ 72MHz) and I seriously doubt even with the slower method calls this code can result in negative impacts.
What's up with UART classes going in there accessing member variables of
RingBuffer
class?Here is a rewritten
RingBuffer
class that no longer allow access to its member variables but can be used too. All condition checking can be rewritten as spin locking on the return value ofputchar
andgetchar