summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-11-03 11:07:06 +0000
committerPádraig Brady <P@draigBrady.com>2015-11-04 23:30:15 +0000
commit697b8ce26549cceffa8745a1dc0f13654173c575 (patch)
tree8abc475a2a9ef4c028a45dd5d32c9a6f361be84a /src
parent7549be4af7e8ac9a088927c35a011da835968b9f (diff)
downloadcoreutils-697b8ce26549cceffa8745a1dc0f13654173c575.tar.xz
ls: avoid redundant processing when already escaping
This is mainly noticeable when the multi-byte code within ls.c is triggered by multi-byte quotes. $ seq 200000 | xargs touch $ time ls-old -U --quoting=locale --hide-control-chars >/dev/null real 0m0.483s $ time ls-new -U --quoting=locale --hide-control-chars >/dev/null real 0m0.430s * src/ls.c (quote_name): Avoid rescanning the output looking for unprintable chars when we know the quoting mode already escapes them. * tests/misc/ls-misc.pl: Add tests for all quoting modes, with and without -q, to verify this assumption.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 8d68a03e1..c22c536c0 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4082,7 +4082,11 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
quotearg_buffer (buf, len + 1, name, -1, options);
}
- if (qmark_funny_chars)
+ enum quoting_style qs = get_quoting_style (options);
+
+ if (qmark_funny_chars
+ && (qs == shell_quoting_style || qs == shell_always_quoting_style
+ || qs == literal_quoting_style))
{
if (MB_CUR_MAX > 1)
{