minor but worthwhile optimization in printf: avoid expensive strspn
[oweals/musl.git] / src / stdio / puts.c
index eb70efdc217bedb99c9db217d96bc706f688d150..5a38a49b975adcad3192eda3148ef1acf55ad0df 100644 (file)
@@ -2,5 +2,9 @@
 
 int puts(const char *s)
 {
-       return -(fputs(s, stdout) < 0 || putchar('\n') < 0);
+       int r;
+       FLOCK(stdout);
+       r = -(fputs(s, stdout) < 0 || putc_unlocked('\n', stdout) < 0);
+       FUNLOCK(stdout);
+       return r;
 }