www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/10/15/02:29:47

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10210150631.AA20605@clio.rice.edu>
Subject: Re: libc' getenv optimization (patch)
To: djgpp-workers AT delorie DOT com
Date: Tue, 15 Oct 2002 01:28:20 -0500 (CDT)
Cc: eliz AT is DOT elta DOT co DOT il, uue AT pauzner DOT dnttm DOT ru
In-Reply-To: <2.7.9.1DQU1.H402DW@pauzner.dnttm.ru> from "Leonid Pauzner" at Oct 15, 2002 05:49:08 AM
X-Mailer: ELM [version 2.5 PL2]
Sender: sandmann AT clio DOT rice DOT edu
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> perhaps a realistic estimates is around 3-10 times for others.
> Preparing procedure set_hash_env() will effectively slowdown putenv() a bit,
> but we putenv less frequently than getenv, right?

If we cache getenv() properly in the tzset(), we'll only call it once.
So there's the chance that you call putenv() more frequently (in 
initialization) than getenv() at runtime.

With the very sparse distribution of letters, I think it would be much
more space efficient to mask the lower 4 or 5 bits for the buckets
(16 or 32 should be fine, 256 is overkill).  This also would speed up
the initial setup.

Here's my proposed patch for ctime.c:

*** ctime.bak   Sun Jun  9 13:20:22 2002
--- ctime.c     Tue Oct 15 01:24:06 2002
*************** tzset(void)
*** 920,926 ****

    /* If environ didn't changed since last time, don't waste time
       looking at $TZ.  */
!   if (lcl_is_set > 0 && __environ_changed == last_env_changed)
      return;

    /* If environ did change, but $TZ wasn't changed since last time we
--- 920,926 ----

    /* If environ didn't changed since last time, don't waste time
       looking at $TZ.  */
!   if (lcl_is_set != 0 && __environ_changed == last_env_changed)
      return;

    /* If environ did change, but $TZ wasn't changed since last time we

- Raw text -


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