Module Name: src Committed By: pooka Date: Tue Sep 29 13:30:17 UTC 2009
Modified Files: src/bin/cp: cp.c Log Message: Remove fts sorting. It was originally put there to copy files before directories since files (usually) are in the same cylinder group and subdirectories aren't. However, this mostly changed with the new ffs dirpref algorithm in 2001. No sorting has two effects: 1) copy appears to be somewhat faster (e.g. on my laptop cp'ing build objdir to tmpfs is 7% faster after the change) 2) source file parameters no longer get randomly shuffled due to fts doing an unstable sort of them. this means that "cp 1 2 3 4 dest/" will copy the files in that order instead of e.g. 3 4 1 2. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/bin/cp/cp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/cp/cp.c diff -u src/bin/cp/cp.c:1.51 src/bin/cp/cp.c:1.52 --- src/bin/cp/cp.c:1.51 Sun Jul 20 00:52:39 2008 +++ src/bin/cp/cp.c Tue Sep 29 13:30:17 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cp.c,v 1.51 2008/07/20 00:52:39 lukem Exp $ */ +/* $NetBSD: cp.c,v 1.52 2009/09/29 13:30:17 pooka Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: cp.c,v 1.51 2008/07/20 00:52:39 lukem Exp $"); +__RCSID("$NetBSD: cp.c,v 1.52 2009/09/29 13:30:17 pooka Exp $"); #endif #endif /* not lint */ @@ -92,7 +92,6 @@ int main(int, char *[]); int copy(char *[], enum op, int); -int mastercmp(const FTSENT **, const FTSENT **); int main(int argc, char *argv[]) @@ -295,7 +294,7 @@ dne = 0; base = 0; /* XXX gcc -Wuninitialized (see comment below) */ - if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL) + if ((ftsp = fts_open(argv, fts_options, NULL)) == NULL) err(EXIT_FAILURE, "%s", argv[0]); /* NOTREACHED */ for (any_failed = 0; (curr = fts_read(ftsp)) != NULL;) { @@ -515,29 +514,3 @@ (void)fts_close(ftsp); return (any_failed); } - -/* - * mastercmp -- - * The comparison function for the copy order. The order is to copy - * non-directory files before directory files. The reason for this - * is because files tend to be in the same cylinder group as their - * parent directory, whereas directories tend not to be. Copying the - * files first reduces seeking. - */ -int -mastercmp(const FTSENT **a, const FTSENT **b) -{ - int a_info, b_info; - - a_info = (*a)->fts_info; - if (a_info == FTS_ERR || a_info == FTS_NS || a_info == FTS_DNR) - return (0); - b_info = (*b)->fts_info; - if (b_info == FTS_ERR || b_info == FTS_NS || b_info == FTS_DNR) - return (0); - if (a_info == FTS_D) - return (-1); - if (b_info == FTS_D) - return (1); - return (0); -}