Date: Fri, 14 Feb 1997 10:47:07 +0100 (MET) From: Robert Hoehne To: DJGPP workers Subject: Patch for _use_lfn.c Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII The patch for _use_lfn.c is to speed up _use_lfn(). When I understood the function correct, the variable 'filesystem_flags' is used to avoid unneccessary calls to getenv(). But with the current implementation it is set only, when "LFN=y". The patch is simply a move of code which had the result for me in a RHIDE test run (which has to call many file system functions, which call that function): without the patch: 506697 calls to getenv() with the patch: 77938 calls to getenv() As you can see, a very big speedup, since getenv() is not the fastest function. (Imagine you have many many env. vars and LFN is the last!!) Robert BTW: I have made a diff -C 6 so you can see exactly the code-moving directly in the patch. *** src/libc/dos/lfn/_use_lfn.c~ Sat Aug 31 21:09:32 1996 --- src/libc/dos/lfn/_use_lfn.c Thu Feb 13 17:59:38 1997 *************** *** 144,169 **** && filesystem_flags != _FILESYS_UNKNOWN) /* paranoia */ return (filesystem_flags & _FILESYS_LFN_SUPPORTED) != 0; else { char *lfnenv; use_lfn_bss_count = __bss_count; last_env_changed = __environ_changed; lfnenv = getenv ("LFN"); if(lfnenv && (tolower (lfnenv[0]) == 'n')) { filesystem_flags &= ~_FILESYS_LFN_SUPPORTED; last_drive = 0; return 0; } } - - if (!same_drive_as_last_time || filesystem_flags == _FILESYS_UNKNOWN) - filesystem_flags = _get_volume_info (path, 0, 0, 0); return (filesystem_flags & _FILESYS_LFN_SUPPORTED) != 0; } #ifdef TEST --- 144,169 ---- && filesystem_flags != _FILESYS_UNKNOWN) /* paranoia */ return (filesystem_flags & _FILESYS_LFN_SUPPORTED) != 0; else { char *lfnenv; + if (!same_drive_as_last_time || filesystem_flags == _FILESYS_UNKNOWN) + filesystem_flags = _get_volume_info (path, 0, 0, 0); + use_lfn_bss_count = __bss_count; last_env_changed = __environ_changed; lfnenv = getenv ("LFN"); if(lfnenv && (tolower (lfnenv[0]) == 'n')) { filesystem_flags &= ~_FILESYS_LFN_SUPPORTED; last_drive = 0; return 0; } } return (filesystem_flags & _FILESYS_LFN_SUPPORTED) != 0; } #ifdef TEST