On Tue, 14 Jun 2016, Lukas Fleischer wrote: > Hi Nicolas, > > On Tue, 14 Jun 2016 at 19:09:15, Nicolas Pitre wrote: > > I just looked again at all the contraptions _I_ wrote (not Junio's) for > > a reason why I went to such extremes in making this code co complicated. > > > > One aspect that is now lost with your patch is the atomic nature of the > > write. See commit ed1902ef5c for the explanation. You could probably > > use sprintf() into a temporary buffer and write it in one go to avoid > > segmented writes from the C library. It's probably not worth having that > > complex code just to avoid a string copy. > > The old code calls fprintf() once per line and so does the new code. The > only difference is that in the old code, the single parts were > concatenated manually while the new code tells fprintf() to do the > concatenation itself while printing. Also note that fprintf() is > buffered -- so even if the new code would call it more often, it would > not really matter. It is not buffered as it writes to stderr. And some C libs do separate calls to write() for every string format specifier. So "%s%s%c" may end up calling write() 3 times depending on the implementation. The example I gave in commit ed1902ef5c is real and I even observed it with strace back then. Nicolas -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html