* lib/vc-mtime.c: Include <stddef.h>.
(git_vc_controlled): Read bytes into a buffer, not one-by-one.
+2025-02-25 Bruno Haible <bruno@clisp.org>
+
+ vc-mtime: Reduce number of read() system calls.
+ * lib/vc-mtime.c: Include <stddef.h>.
+ (git_vc_controlled): Read bytes into a buffer, not one-by-one.
+
2025-02-25 Bruno Haible <bruno@clisp.org>
vc-mtime: Improve comment.
/* Specification. */
#include "vc-mtime.h"
+#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
return false;
/* Read the subprocess output, and test whether it is non-empty. */
- size_t count = 0;
- char c;
+ ptrdiff_t count = 0;
- while (safe_read (fd[0], &c, 1) > 0)
- count++;
+ for (;;)
+ {
+ char buf[1024];
+ ptrdiff_t n = safe_read (fd[0], buf, sizeof (buf));
+ if (n > 0)
+ count += n;
+ else
+ break;
+ }
close (fd[0]);