5 ms·
I was lost after the second code example (I'm not a c programmer but I'm quite comfortable in C-like languages (Go, Python, Java). void xevents(void)
by Matt3o12_ 10y ago
I was lost after the second code example (I'm not a c programmer but I'm quite comfortable in C-like languages (Go, Python, Java).
void
xevents(void)
{
if (poll() || poll())
while (poll()) {
/* ... */
}
}
What advantages does this code produce and how is it related to the first example? Why would calling poll 3 times have any advantages if either call 1 or 2 must be true and call 3, and the following ones must be true as well?
- adamnemecek 10y agoThe article is about how this repeated polling is wrong but the fact that it's happening is not transparent from just looking at the code.
- svantana 10y agoThat was the whole point, that convoluted source code can hide inefficiencies like this.
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- darklajid 10y agoThat's a humorous translation of the first code. He claims (I'm no expert either) that xtermAppPending() is poll(), GetBytesAvailable() is poll() and then xevents is invoked, which calls xtermAppPending() again in a loop. The code you're confused about is basically combining the two previous methods (hence: 'manual inlining' with a wink) and replacing both xtermAppPending() and GetBytesAvailable() with poll() to make the problem stand out.