summaryrefslogtreecommitdiff
path: root/defs.h
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-03-06 23:44:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-03-06 23:44:23 +0100
commit5198ed4bb36e3105a1f12bb3250bee78b6e0dd72 (patch)
tree8b16d7227568b2e1b042cf882876feab9dbed9b9 /defs.h
parent76f61bec5e3dea55b2b50f2e8009642977b414e5 (diff)
downloadstrace-5198ed4bb36e3105a1f12bb3250bee78b6e0dd72.tar.gz
strace-5198ed4bb36e3105a1f12bb3250bee78b6e0dd72.tar.bz2
strace-5198ed4bb36e3105a1f12bb3250bee78b6e0dd72.tar.xz
Open-code isprint(c) and isspace(c)
We don't call setlocale, thus we always use C locale. But libc supports various other locales, and therefore its ctype interface is general and at times inefficient. For example, in glibc these macros result in function call, whereas for e.g. isprint(c) just c >= ' ' && c <= 0x7e suffices. By open-coding ctype checks (we have only 4 of them) we avoid function calls, we get smaller code: text data bss dec hex filename 245127 680 5708 251515 3d67b strace_old 245019 676 5708 251403 3d60b strace and we don't link in ctype tables (beneficial for static builds). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'defs.h')
-rw-r--r--defs.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/defs.h b/defs.h
index c20fcc6..bb4003f 100644
--- a/defs.h
+++ b/defs.h
@@ -52,7 +52,10 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
-#include <ctype.h>
+/* Open-coding isprint(ch) et al proved more efficient than calling
+ * generalized libc interface. We don't *want* to do non-ASCII anyway.
+ */
+/* #include <ctype.h> */
#include <string.h>
#include <errno.h>
#include <signal.h>