Am Wed, 1 Jun 2022 08:01:19 -0400
schrieb Scott Kostyshak <skost...@lyx.org>:

> On Wed, Jun 01, 2022 at 10:59:47AM +0200, Kornel Benko wrote:
> > Am Tue, 31 May 2022 12:20:55 +0200
> > schrieb Kornel Benko <kor...@lyx.org>:
> >   
> > > At least here is what I can see:
> > > 
> > >   $ wc styFiles.lst
> > >    11429  11429 812660 styFiles.lst
> > >   $ sort styFiles.lst | uniq| wc
> > >      5943    5943  422983
> > > 
> > >   Kornel  
> > 
> > Attached patch fixes it. OK to commit?  
> 
> I checked and I have duplicates also. Thanks for fixing this!
> 
> The patch looks good to me, +1 to commit. Here are some comments that
> after thinking more I'm guessing you should _not_ incorporate:
> 
> I was wondering whether a set would be more appropriate than a
> dictionary since the "1" seems irrelevant from what I can see. But after
> some searching I did not find any performance advantage of using a set.
> And dictionaries are more common, so I think your patch is good.
> 
> One other minor comment is I wonder if preallocating the dictionary
> could speed things up a bit? But then I realized that the script speed
> is probably dominatinated by something else (I/O?), so probably better
> to avoid complication for something that doesn't have a non-trivial
> impact on speed.
> 
> Scott

Thanks Scott. I was hoping someone has a better idea. In fact, there is.
Simply move
        visited = set()
to outside of the 'for'-loop.
The resulting output is the same as with my previous patch.

        Kornel

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel
diff --git a/lib/scripts/TeXFiles.py b/lib/scripts/TeXFiles.py
index 16b7df2e8b..a5787eaacb 100755
--- a/lib/scripts/TeXFiles.py
+++ b/lib/scripts/TeXFiles.py
@@ -109,16 +109,16 @@ for type in types:
     # remove excessive //
     dirs = re.sub('//+', '/', dirs)
     
     file_ext = '.' + type
     out = open(outfile, 'w')
+    visited = set()
     for dir in dirs.split(path_sep):
         # for each valid directory
         if not os.path.isdir(dir):
             continue
         # walk down the file hierarchy
-        visited = set()
         for root,dirs,files in os.walk(dir, followlinks=True):
             # prevent inifinite recursion
             recurse = []
             for dir in dirs:
                 dirname = os.path.join(root, dir)

Attachment: pgpLHzuPqazpY.pgp
Description: Digitale Signatur von OpenPGP

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to