TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Juha-Matti Tapio
from: Darin McBride
date: 1998-06-25 19:54:30
subject: Coding style

> const size_t read_target = r[i]->target;
> const short* p_typeid    = s[read_target].typeid;
> fread(p_typeid, sizeof(*p_typeid), 1, f);

> That I find to be much improved.  Just my opinion, of
> course.

 JT> That might be worth considering. But it looks a bit 
 JT> messy since there is so much code to simplify one 
 JT> function call. On the other hand I use lot's of similar 
 JT> fread()s on the project that the sample was taken from.

Sometimes simpler code is shorter, sometimes it is longer.  Interestingly,
the above code should be optimizable into the original code, meaning it
should be just as fast, and just as short (codesize).  So it isn't really
longer to the CPU during runtime.  (Not that this should matter too much -
you're doing file I/O which is inherently slower than the memory tricks you
do to generate the first parameter...)


---
* Origin: Tanktalus' Tower BBS (1:250/102)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728
SEEN-BY: 670/213 218
@PATH: 250/102 201 99 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.