]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
numfmt: improve processing throughput by 800%
authorPádraig Brady <P@draigBrady.com>
Fri, 2 May 2014 00:23:21 +0000 (01:23 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 2 May 2014 01:02:20 +0000 (02:02 +0100)
The devmsg() calls that took quote_n() arguments,
didn't normally output anything, but still incurred
the overhead of those quote_n() calls.

* src/numfmt.c (devmsg): Move the inline function
with _internal_ enablement check to...
* src/system.h: ...here as a variadic macro, with
the enablement check at the outer level.
* src/factor.c: As per numfmt.c but there is no
performance change in this case.
* NEWS: Mention the significant performance improvement.

NEWS
src/factor.c
src/numfmt.c
src/system.h

diff --git a/NEWS b/NEWS
index 92ab59df45768f67f4cf128035c9356cb7c79996..50303f99ae2b7b039278bc0b81d64f6845924636 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,7 @@ GNU coreutils NEWS                                    -*- outline -*-
 
   numfmt supports zero padding of numbers using the standard printf
   syntax of a leading zero, for example --format="%010f".
+  Also throughput was improved by up to 800% by avoiding redundant processing.
 
   shred now supports multiple passes on GNU/Linux tape devices by rewinding
   the tape before each pass, avoids redundant writes to empty files,
index c55edb894574fb3e700a7e8472cb7ed7b2757cd3..63924d5452be1ad932598d8ddcf31748cba8428b 100644 (file)
@@ -689,22 +689,6 @@ verify (W <= WIDE_UINT_BITS);
    This flag is used only in the GMP code.  */
 static bool dev_debug = false;
 
-/* Like error(0, 0, ...), but without an implicit newline.
-   Also a noop unless the global DEV_DEBUG is set.
-   TODO: Replace with variadic macro in system.h or
-   move to a separate module.  */
-static inline void
-devmsg (char const *fmt, ...)
-{
-  if (dev_debug)
-    {
-      va_list ap;
-      va_start (ap, fmt);
-      vfprintf (stderr, fmt, ap);
-      va_end (ap);
-    }
-}
-
 /* Prove primality or run probabilistic tests.  */
 static bool flag_prove_primality = true;
 
index c7448752c888691fd13578ad251602c735dd0ec3..e8f53fc3f7b3b8945611f37fb5f3a416c950f420 100644 (file)
@@ -198,22 +198,6 @@ static int decimal_point_length;
 /* debugging for developers.  Enables devmsg().  */
 static bool dev_debug = false;
 
-/* Like error(0, 0, ...), but without an implicit newline.
-   Also a noop unless the global DEV_DEBUG is set.
-   TODO: Replace with variadic macro in system.h or
-   move to a separate module.  */
-static inline void
-devmsg (char const *fmt, ...)
-{
-  if (dev_debug)
-    {
-      va_list ap;
-      va_start (ap, fmt);
-      vfprintf (stderr, fmt, ap);
-      va_end (ap);
-    }
-}
-
 static inline int
 default_scale_base (enum scale_type scale)
 {
index a9588e779b96bb79b2eb9ccdfb725089490aae0c..f295ad1c2e4287735e92c7a9ff7b2b4be275efcd 100644 (file)
@@ -617,6 +617,16 @@ usable_st_size (struct stat const *sb)
 
 void usage (int status) ATTRIBUTE_NORETURN;
 
+/* Like error(0, 0, ...), but without an implicit newline.
+   Also a noop unless the global DEV_DEBUG is set.  */
+#define devmsg(...)                    \
+  do                                   \
+    {                                  \
+      if (dev_debug)                   \
+        fprintf (stderr, __VA_ARGS__); \
+    }                                  \
+  while (0)
+
 #define emit_cycle_warning(file_name)  \
   do                                   \
     {                                  \