nmh-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-commits] nmh ChangeLog aclocal.m4 configure.in uip/folder.c


From: Peter Maydell
Subject: [Nmh-commits] nmh ChangeLog aclocal.m4 configure.in uip/folder.c
Date: Tue, 05 Aug 2008 21:06:00 +0000

CVSROOT:        /sources/nmh
Module name:    nmh
Changes by:     Peter Maydell <pm215>   08/08/05 21:06:00

Modified files:
        .              : ChangeLog aclocal.m4 configure.in 
        uip            : folder.c 

Log message:
        uip/folder.c: chdir(nmhdir) in main rather than in dodir, which
        is called many times.  Drop the chdir in get_folder_info, which
        served no purpose at all.  If struct stat has d_type (BSD), use
        that to skip processing (strcmp, stat, and so on) of message
        files, mostly undoing the slow-down from the last change.
        Plus autoconf machinery to detect d_type field. Patch from Eric 
Gillespie.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/nmh/ChangeLog?cvsroot=nmh&r1=1.285&r2=1.286
http://cvs.savannah.gnu.org/viewcvs/nmh/aclocal.m4?cvsroot=nmh&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/nmh/configure.in?cvsroot=nmh&r1=1.84&r2=1.85
http://cvs.savannah.gnu.org/viewcvs/nmh/uip/folder.c?cvsroot=nmh&r1=1.15&r2=1.16

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/nmh/nmh/ChangeLog,v
retrieving revision 1.285
retrieving revision 1.286
diff -u -b -r1.285 -r1.286
--- ChangeLog   5 Aug 2008 19:09:03 -0000       1.285
+++ ChangeLog   5 Aug 2008 21:06:00 -0000       1.286
@@ -1,3 +1,16 @@
+2008-08-05  Eric Gillespie  <address@hidden>
+
+       * uip/folder.c: chdir(nmhdir) in main rather than in dodir, which
+       is called many times.  Drop the chdir in get_folder_info, which
+       served no purpose at all.  If struct stat has d_type (BSD), use
+       that to skip processing (strcmp, stat, and so on) of message
+       files, mostly undoing the slow-down from the last change.
+
+       * configure.in: Call CHECK_TYPE_STRUCT_DIRENT_D_TYPE.
+
+       * aclocal.m4: Add CHECK_TYPE_STRUCT_DIRENT_D_TYPE from
+       GNU coreutils.
+
 2008-08-04  Eric Gillespie  <address@hidden>
 
        * uip/folder.c: Simplify dodir/addir/addfold.  Dump hacky

Index: aclocal.m4
===================================================================
RCS file: /sources/nmh/nmh/aclocal.m4,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- aclocal.m4  24 Dec 2005 17:17:38 -0000      1.5
+++ aclocal.m4  5 Aug 2008 21:06:00 -0000       1.6
@@ -84,3 +84,55 @@
   :
 fi
 ])dnl
+
+dnl ----------------
+dnl CHECK FOR d_type
+dnl ----------------
+dnl
+dnl From Jim Meyering.
+dnl
+dnl Check whether struct dirent has a member named d_type.
+dnl
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+# Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
+  [AC_REQUIRE([AC_HEADER_DIRENT])dnl
+   AC_CACHE_CHECK([for d_type member in directory struct],
+                  jm_cv_struct_dirent_d_type,
+     [AC_TRY_LINK(dnl
+       [
+#include <sys/types.h>
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+#else /* not HAVE_DIRENT_H */
+# define dirent direct
+# ifdef HAVE_SYS_NDIR_H
+#  include <sys/ndir.h>
+# endif /* HAVE_SYS_NDIR_H */
+# ifdef HAVE_SYS_DIR_H
+#  include <sys/dir.h>
+# endif /* HAVE_SYS_DIR_H */
+# ifdef HAVE_NDIR_H
+#  include <ndir.h>
+# endif /* HAVE_NDIR_H */
+#endif /* HAVE_DIRENT_H */
+       ],
+       [struct dirent dp; dp.d_type = 0;],
+
+       jm_cv_struct_dirent_d_type=yes,
+       jm_cv_struct_dirent_d_type=no)
+     ]
+   )
+   if test $jm_cv_struct_dirent_d_type = yes; then
+     AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1,
+       [Define if there is a member named d_type in the struct describing
+        directory headers.])
+   fi
+  ]
+)

Index: configure.in
===================================================================
RCS file: /sources/nmh/nmh/configure.in,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- configure.in        13 May 2008 02:39:05 -0000      1.84
+++ configure.in        5 Aug 2008 21:06:00 -0000       1.85
@@ -1,7 +1,7 @@
 dnl
 dnl configure.in -- autoconf template for nmh
 dnl
-dnl $Id: configure.in,v 1.84 2008/05/13 02:39:05 levine Exp $
+dnl $Id: configure.in,v 1.85 2008/08/05 21:06:00 pm215 Exp $
 dnl
 
 dnl 2.13 definitely chokes; 2.53 is the earliest version I've tested.
@@ -950,6 +950,8 @@
 fi
 AC_MSG_RESULT($nmh_cv_union_wait)
 
+CHECK_TYPE_STRUCT_DIRENT_D_TYPE()
+
 dnl -------------
 dnl CHECK SIGNALS
 dnl -------------

Index: uip/folder.c
===================================================================
RCS file: /sources/nmh/nmh/uip/folder.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- uip/folder.c        5 Aug 2008 19:09:03 -0000       1.15
+++ uip/folder.c        5 Aug 2008 21:06:00 -0000       1.16
@@ -4,7 +4,7 @@
  *             -- push/pop a folder onto/from the folder stack
  *             -- list the folder stack
  *
- * $Id: folder.c,v 1.15 2008/08/05 19:09:03 pm215 Exp $
+ * $Id: folder.c,v 1.16 2008/08/05 21:06:00 pm215 Exp $
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -365,6 +365,9 @@
        /*
         * If no folder is given, do them all
         */
+       /* change directory to base of nmh directory for dodir */
+       if (chdir (nmhdir) == NOTOK)
+           adios (nmhdir, "unable to change directory to");
        if (!argfolder) {
            if (msg)
                admonish (NULL, "no folder given for message %s", msg);
@@ -422,10 +425,6 @@
 
     start = foldp;
 
-    /* change directory to base of nmh directory */
-    if (chdir (nmhdir) == NOTOK)
-       adios (nmhdir, "unable to change directory to");
-
     addir (dir);
 
     for (i = start; i < foldp; i++) {
@@ -441,7 +440,6 @@
 get_folder_info (char *fold, char *msg)
 {
     int        i, retval = 1;
-    char *mailfile;
     struct msgs *mp = NULL;
 
     i = total_folders++;
@@ -463,9 +461,6 @@
     fi[i].others = 0;
     fi[i].error  = 0;
 
-    mailfile = m_maildir (fold);
-
-    if (!chdir (mailfile)) {
        if ((ftotal > 0) || !fshort || msg || fpack) {
            /*
             * create message structure and get folder info
@@ -497,9 +492,6 @@
 
            folder_free (mp); /* free folder/message structure */
        }
-    } else {
-       fi[i].error = 1;
-    }
 
     if (frecurse && (fshort || fi[i].others) && (fi[i].error == 0))
        dodir (fold);
@@ -669,6 +661,7 @@
     struct stat st;
     struct dirent *dp;
     DIR * dd;
+    int child_is_folder;
 
     if (!(dd = opendir (name))) {
        admonish (name, "unable to read directory ");
@@ -682,11 +675,26 @@
     }
 
     while ((dp = readdir (dd))) {
+       /* If the system supports it, try to skip processing of children we
+        * know are not directories or symlinks. */
+       child_is_folder = -1;
+#if defined(HAVE_STRUCT_DIRENT_D_TYPE)
+       if (dp->d_type == DT_DIR) {
+           child_is_folder = 1;
+       } else if (dp->d_type != DT_LNK && dp->d_type != DT_UNKNOWN) {
+           continue;
+       }
+#endif
        if (!strcmp (dp->d_name, ".") || !strcmp (dp->d_name, "..")) {
            continue;
        }
        child = concat (prefix, dp->d_name, (void *)NULL);
-       if (stat (child, &st) != -1 && S_ISDIR(st.st_mode)) {
+       /* If we have no d_type or d_type is DT_LNK or DT_UNKNOWN, stat the
+        * child to see what it is. */
+       if (child_is_folder == -1) {
+           child_is_folder = (stat (child, &st) != -1 && S_ISDIR(st.st_mode));
+       }
+       if (child_is_folder) {
            /* addfold saves child in the list, don't free it */
            addfold (child);
        } else {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]