mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
realpath: avoid the use of printf
This was seen to give an 11% performance improvement. * src/realpath.c (relpath): Avoid using printf. (process_path): Likewise.
This commit is contained in:
1 parent
c5cb291939
commit
9d46b25ded
1 file changed
+11
-8
+11
-8
@@ -181,26 +181,27 @@ relpath (const char *can_fname)
|
||||
to a common directory. Then output the remainder of fname. */
|
||||
if (*relto_suffix)
|
||||
{
|
||||
printf ("%s", "..");
|
||||
fputs ("..", stdout);
|
||||
for (; *relto_suffix; ++relto_suffix)
|
||||
{
|
||||
if (*relto_suffix == '/')
|
||||
printf ("%s", "/..");
|
||||
fputs ("/..", stdout);
|
||||
}
|
||||
|
||||
if (*fname_suffix)
|
||||
printf ("/%s", fname_suffix);
|
||||
{
|
||||
putchar ('/');
|
||||
fputs (fname_suffix, stdout);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*fname_suffix)
|
||||
printf ("%s", fname_suffix);
|
||||
fputs (fname_suffix, stdout);
|
||||
else
|
||||
printf ("%c", '.');
|
||||
putchar ('.');
|
||||
}
|
||||
|
||||
putchar (use_nuls ? '\0' : '\n');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -228,7 +229,9 @@ process_path (const char *fname, int can_mode)
|
||||
}
|
||||
|
||||
if (!relpath (can_fname))
|
||||
printf ("%s%c", can_fname, (use_nuls ? '\0' : '\n'));
|
||||
fputs (can_fname, stdout);
|
||||
|
||||
putchar (use_nuls ? '\0' : '\n');
|
||||
|
||||
free (can_fname);
|
||||
|
||||
|
||||
Reference in new issue
Block a user