[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] use test -s to speed up check for empty file
From: |
Paolo Bonzini |
Subject: |
[PATCH] use test -s to speed up check for empty file |
Date: |
Fri, 5 Oct 2007 09:56:32 +0200 |
This is the source of run-time performance improvements. It uses
"test -s" to know if there will be output from diff, and skips the
invocation if this is not the case. I was surprised too by the
difference, but it's there to see. I abstracted this into a
shell function too.
2007-10-04 Paolo Bonzini <address@hidden>
* general.m4 (AT_INIT): Add at_diff_devnull shell function,
using test -s to avoid useless diff invocations.
(_AT_CHECK): Use it.
---
ChangeLog | 6 ++++++
lib/autotest/general.m4 | 9 +++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 3de93df..b87ba96 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -256,6 +256,11 @@ at_check_status () {
esac
}
+at_diff_devnull () {
+ test -s "$[1]" || return 0
+ $at_diff "$at_devnull" "$[1]"
+}
+
# Load the config file.
for at_file in atconfig atlocal
do
@@ -1532,14 +1537,14 @@ m4_case([$4],
stderr, [echo stderr:; tee stderr <"$at_stderr"],
ignore, [echo stderr:; cat "$at_stderr"],
experr, [$at_diff experr "$at_stderr" || at_failed=:],
- [], [$at_diff "$at_devnull" "$at_stderr" || at_failed=:],
+ [], [at_diff_devnull "$at_stderr" || at_failed=:],
[echo >>"$at_stderr";
AS_ECHO(["m4_ifval([$7],[AS_ESCAPE([$4])],[$4])"]) | $at_diff - "$at_stderr" ||
at_failed=:])
dnl Check stdout.
m4_case([$3],
stdout, [echo stdout:; tee stdout <"$at_stdout"],
ignore, [echo stdout:; cat "$at_stdout"],
expout, [$at_diff expout "$at_stdout" || at_failed=:],
- [], [$at_diff "$at_devnull" "$at_stdout" || at_failed=:],
+ [], [at_diff_devnull "$at_stdout" || at_failed=:],
[echo >>"$at_stdout";
AS_ECHO(["m4_ifval([$7],[AS_ESCAPE([$3])],[$3])"]) | $at_diff - "$at_stdout" ||
at_failed=:])
m4_if([$2], [ignore], [at_check_skip], [at_check_status m4_default([$2],
[0])]) $at_status "$at_srcdir/AT_LINE"
AS_IF($at_failed, [$5], [$6])
--
1.5.2.4