[elinks-dev] Re: elinks - jonas: Minor optimization to only do two multipl...

Petr Baudis pasky at ucw.cz
Sat Oct 4 15:26:10 PDT 2003


Dear diary, on Sun, Oct 05, 2003 at 12:22:16AM CEST, I got a letter,
where Jonas Fonseca <fonseca at diku.dk> told me, that...
> Petr Baudis <pasky at ucw.cz> wrote Sat, Oct 04, 2003:
> > Dear diary, on Mon, Sep 29, 2003 at 01:44:37AM CEST, I got a letter,
> > where cvs at pasky.ji.cz told me, that...
> > > This is an automated notification of a change to the ELinks CVS tree.
> > > 
> > > Author: jonas
> > > Module: elinks
> > >    Tag: <TRUNK>
> > >   Date: Sun Sep 28 23:44:37 2003 GMT
> > > 
> > > ---- Log message:
> > > 
> > > Minor optimization to only do two multiplications.
> > > 
> > > 
> > > 
> > > ---- Files affected:
> > > 
> > > elinks/src/util:
> > >    memory.h (1.16 -> 1.17) 
> > >     http://cvsweb.elinks.or.cz/cvsweb.cgi/elinks/src/util/memory.h.diff?r1=1.16&r2=1.17&f=u
> > > 
> > > 
> > > ---- Diffs:
> > > 
> > > Index: elinks/src/util/memory.h
> > > diff -u elinks/src/util/memory.h:1.16 elinks/src/util/memory.h:1.17
> > > --- elinks/src/util/memory.h:1.16	Sun Sep 28 21:55:35 2003
> > > +++ elinks/src/util/memory.h	Mon Sep 29 01:44:32 2003
> > > @@ -111,15 +111,18 @@
> > >  	if (newsize > oldsize) {
> > >  		unsigned char *data;
> > >  
> > > +		newsize *= objsize;
> > > +		oldsize *= objsize;
> > > +
> > >  #ifdef LEAK_DEBUG
> > > -		data = debug_mem_realloc(file, line, *ptr, newsize * objsize);
> 							   ^^^^^^ #1 ^^^^^^^^
> > > +		data = debug_mem_realloc(file, line, *ptr, newsize);
> > >  #else
> > > -		data = mem_realloc(*ptr, newsize * objsize);
> > > +		data = mem_realloc(*ptr, newsize);
> > >  #endif
> > >  		if (!data) return NULL;
> > >  
> > >  		*ptr = (void *)data;
> > > -		memset(&data[oldsize * objsize], 0, (newsize - oldsize) * objsize);
> 			     ^^^^^^ #2 ^^^^^^^^     ^^^^^^^^^^^^ #3 ^^^^^^^^^^^^^ 
> > > +		memset(&data[oldsize], 0, newsize - oldsize);
> > >  	}
> > >  
> > >  	return *ptr;
> > 
> > Actually, we were doing two multiplications before as well... whatever
> > ;-).
> 
> 1 + 2 = 2?

/me slaps himself with a mechanical 150lbs calculator featuring
additional external punch card device and ten-digits interface.

-- 
 
				Petr "Pasky" Baudis
.
To get something done, a committee should consist of no more than three
persons, two of them absent.
.
Stuff: http://pasky.ji.cz/



More information about the elinks-dev mailing list