> In the tests I'm calling the function GetFdWidth() twice for every > module, which may incur in a bit overhead.. > > There's a global var called fd_width. I don't know if I should use the > it instead, but supose it should be removed.. I've also considered the > use of a static global var to improve performance. > > On the other hand, in this case we don't care for the number of > maximum opened fds - if the number is too big then the open pipe call > will fail. What we want is the max fdset size, so maybe we can just > use FD_SETSIZE.
That's what GetFdWidth() does, but the fd_width variable is there for exactly this reason. I see the code is a mess now. Suggestion: ** Remove fd_width in fvwm.c and GetFdWidth() in libs/System.c. ** Add a global variable and a function to fvwmlib.h: extern const fd_set_size_t fvwmlib_max_fd; void fvwmlib_init_max_fd(void); ** Define both in libs/System.c: const fd_set_size_t fvwmlib_max_fd = (fd_set_size_t)-9999999; void fvwmlib_init_max_fd(void) { /* init fvwmlib_max_fd with code from old * GetFdWidth() function. */ } ** replace "fd_width = GetFdWidth();" in fvwm.c with "fvwmlib_init_mx_fd();". ** Use fvwmlib_max_fd everywhere. ** If you are bored, do the same in all the modules :-P > So what's the best solution? > > About the fd_width global, it is used for the select calls. I don't > know if it's better performance-wise to ask for the whole range of > possible pipes (like now) or keep the record of the bigger pipe fd.. Of course it would be faster during the select() calls, but input is relatively rare. I don't think keeping a sorted list of open module fds woulb be justified. After all, the fdset is just a relatively small bit field, not megabytes of memory. Ciao Dominik ^_^ ^_^ -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer