| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Coding style |
DM> Well, that's better, but... DM> const size_t read_target = r[i]->target; DM> const short* p_typeid = s[read_target].typeid; DM> fread(p_typeid, sizeof(*p_typeid), 1, f); DM> That I find to be much improved. Just my opinion, of course. AR> Yes, but your C++ bias is showing ... Which, the const's? Actually, that's more than just C++ bias: it's me giving the compiler a couple of hints about the code. By telling the compiler that this value isn't going to change, perhaps it may be able to make a few optimisations. For example, in this case, if neither read_target nor p_typeid are used after the fread, perhaps the compiler (in optimise mode) may decide not to allocate real stack space for it, but to simply build the fread parameter list with the right values, discarding the values on return. Sure, C++ compilers are more apt to perform this optimisation (I think), but with most current C compilers also being C++ compilers, I would imagine that the optimisation engine would be common... And those straight-C compilers shouldn't really be that far off the mark. :-) ---* 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™.