Date: Wed, 20 Jun 2001 20:51:06 +0300 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: Martin Str|mberg 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 Precedence: bulk > From: Martin Str|mberg > 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.