Lloyd Bryant wrote:
> The attached patch is a cleanup of the recurse_scan_intern() function in 
> src/core/share.c.  I was looking at the code, and noticed redundant calls 
> to stat(), and by the time I got through eliminating them the structure of 
> the code had changed noticeably.

Thanks for your patch, I've integrated it.
 
> src/core/share.c:
>  Modified recurse_scan_intern()
>  Added shared_file_valid_extension()
> src/core/share/h:
>  Added shared_file_valid_extension() prototype

As said, don't export it unless you want to use it elsewhere. It was a good
idea to extract this code and put it into its own function in any case though.
Due to this I also found an old bug in it and optimized it a bit. I think
it would be better to use a hashtable instead of a list because even by default
there are dozens of extensions.

> src/lib/file.h
>  Added S_ISLNK macro (this seemed like the correct file for this)

lib/misc.[ch] is the right place for miscelleaneous stuff but in this case I
added it to common.h because it's only provided for portability. If one had
to include a certain header file to be sure it's available, that would be
likely forgotten. That's also why we include virtually every system header
file from common.h. It would be too much of a hassle to ensure you're including
all necessary files otherwise as this differs for each platform.

> Testing shows that the new code is slightly faster than the original (about 
> 2% faster for 7659 files processed).

I've added another minor optimization. If symlinked files *and* directories
are supposed to be ignored, we can skip the stat() and proceed to the next
entry.

-- 
Christian

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Gtk-gnutella-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to