delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/20/13:55:48

Date: Wed, 20 Jun 2001 20:51:06 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Martin Str|mberg <ams AT ludd DOT luth DOT se>
Message-Id: <3596-Wed20Jun2001205105+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp-workers AT delorie DOT com
In-reply-to: <200106201656.SAA22736@father.ludd.luth.se> (message from Martin
Str|mberg on Wed, 20 Jun 2001 18:56:13 +0200 (MET DST))
Subject: Re: More signed/unsigned issues
References: <200106201656 DOT SAA22736 AT father DOT ludd DOT luth DOT se>
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

> From: Martin Str|mberg <ams AT ludd DOT luth DOT se>
> Date: Wed, 20 Jun 2001 18:56:13 +0200 (MET DST)
> 
> According to Eli Zaretskii:
> > >        while (s > 0) {
> > > -       if (--f->_cnt > -f->_bufsiz && *(const char *)ptr != '\n')
> > > +       if (--f->_cnt > -(long signed int)f->_bufsiz && *(const char *)ptr != 'n')
> > >           *f->_ptr++ = *(const char *)ptr++;
> > 
> > Isn't it better to introduce a new `long signed int' variable, assign
> > to it the value of f->_bufsiz, and then use that new variable instead
> > of f->_bufsiz?  Let the optimizer do the dirty work ;-)
> 
> Like this?:
> 
>      if (f->_flag & _IOLBF)
>        while (s > 0) {
> -       if (--f->_cnt > -f->_bufsiz && *(const char *)ptr != '\n')
> +       long signed int negative_bufsiz = -f->_bufsiz;
> +
> +       if (--f->_cnt > negative_bufsiz && *(const char *)ptr != '\n')
>           *f->_ptr++ = *(const char *)ptr++;

Yes, exactly.

- Raw text -


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