When content of a large directory is being sorted by file names, a
significant amount of CPU time is spent in str_utf8_normalize() that is
called from str_utf8_create_key_gen().
For example, /usr/bin/ contains 5437 files on my Archlinux box. Running
mc /usr/bin/ /usr/bin/ takes approx. 75 000 000 CPU instructions to sort
file names, or 25% of total program run time. From these 75 000 000
instructions, 42 500 000 instruction are spent in str_utf8_normalize().
str_utf8_normalize() uses g_utf8_normalize() to do the work.
g_utf8_normalize() is a heavyweight function, that converts UTF-8 into
UCS-4, does the normalization and then converts UCS-4 back into UTF-8.
Since file names are composed of ASCII characters in most cases, we can
speed up str_utf8_normalize() by checking if the heavyweight Unicode
normalization is actually needed. Normalization of ASCII string is
no-op, so it is effectively "normalized" by just strdup().
With this patch, running mc /usr/bin/ /usr/bin/ requires just 37 000 000
instructions to sort the file names (down from 75 000 000) and 4 500 000
instuctions to do str_utf8_normalize() (down from 42 500 000).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This patch was supposed to get committed as part of #3571 but this never
happened. We commit it now as we depend on its functionality for the next
commit.
Signed-off-by: Mooffie <mooffie@gmail.com>
Found by GCC 6.2.0.
color-internal.c:186:33: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'int' [-Werror=format=]
Signed-off-by: Andreas Mohr <and@gmx.li>
MC truncates timestamps during file copy and drops sub-second precision.
Make use of utimensat(), introduced in Linux kernel 2.6.22 (and since
2.6.26 compatible with POSIX-1.2008).
Signed-off-by: Andrey Gursky <andrey.gursky@e-mail.ua>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
We also improve the documentation of vfs_parse_filedate(), which does the
actual work.
Note that in the user-facing documentation (extfs/helpers/README) there are
two things we prefer *not* to mention about vfs_parse_filedate's ability:
* Accepting the format "MM-DD-YY hh:mm[:ss]", as this two-digit year is
more likely to confuse readers of such dates.
* Accepting '/', instead of '-', as the separator in MM-DD-YYYY. (Considering
that some scripts do use '/', maybe we should mention it?)
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This message is sent to widgets'owner when widget's focus state is
changed.
Find file dialog: fix initial draw of ignore directories input line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
scanf("%x") knows to eat up this prefix[1][2], so we don't need to do this
ourselves.
[1] K&R's "The C Programming Language" documents "%x" as "hexadecimal
integer (with or without leading 0x or 0X)"
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/scanf.html
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Note: considering that this feature hasn't worked, we may consider removing it
entirely or partially (e.g., escaping) in order to simplify the code, as nobody
has grown used to it. It seems, based on the "hex mode" mentioned in the manual
page, that in the past there was no "normal" search in hex mode, and quoted
strings were the only easy way to look for text. This is no longer the case
nowadays.
Note: the characters in the quoted string are copied out as-is to the regexp.
No regexp-quoting is currently done. We may want to revisit this issue when we
work on ticket #3695.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>