-
-
Notifications
You must be signed in to change notification settings - Fork 7k
a simpler, shorter and faster write() implementation for SofftwareSerial #1933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ide-1.5.x
Are you sure you want to change the base?
Conversation
no... tx_high_ are member-function pointers ;) which need to be called by operator "." or "->" |
Oh, right, indeed :-) |
I had the same idea about the zero/one value and keeping the original tx_pin_write() I'm not aware, that function pointers will be any slower compared to direct invokation. But yes, they do need some extra space.
The macros are just here for better readabilty - i don't mind to ommit them...
Maybe tx_high/tx_low arent really good names - but better ones didn't come to my mind ;) But then again, in the inverted case they are actualy logical since high means low and low means high - exactly what do mem_fun do ;) And to be honest, having variables zero/one for high/low and switched for the inverted case isn't really different from the inverted member-functions ;)
what do you mean by that ? |
Right, I see what you mean there. However, I don't think that extra if is bad for readability of the source. In fact, I'd rather have this extra if, then having to use macros to hide the (somewhat confusing and IMHO ugly) indirect member-call syntax. As for the final performance of the code, if that's what you're concerned with, I don't really think that extra if will be bigger or slower than the indirect call. In fact, the compiler will probably inline the
You need to load the address into the Z register (IIRC, could by X or Y), which takes some time and then IIRC the As for the low/high vs one/zero. It's true that there's the concept of "logical low/high" vs "physical low/high", which can be inverted when doing inverse_logic. However, I'd say that referring to "logical low high" as "zero/one" would make the code a bit less confusing :-)
I mean that the subject of this commit does not discuss this comment and the comment is not really related to the change at hand. Furthermore, having questions like these in the source really isn't very meaningful - they'll only confuse future readers of the source. If you have a question, a mailling list or other discussion medium is the way to answer it. If the check turns out to be unneeded, then the check can be removed. If not, a comment could be added explaining why it is needed (since it is apparently unclear now). |
|
as the subjects say...a simpler, more effcient (less "if") implementation for write