delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/02/14/04:59:44

Date: Fri, 14 Feb 1997 10:47:07 +0100 (MET)
From: Robert Hoehne <robert DOT hoehne AT mathematik DOT tu-chemnitz DOT de>
To: DJGPP workers <djgpp-workers AT delorie DOT com>
Subject: Patch for _use_lfn.c
Message-Id: <Pine.HPP.3.95q.970214104532.28681A-100000@newton.mathematik.tu-chemnitz.de>
Mime-Version: 1.0

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
  



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019