On Jan 15, 2011, at 7:10 AM, Tom Browder wrote:

> I have seen several places in the tree with chunks of code like this
> (from fedex_main.c):

Changes to source code in src/other is generally discouraged, with  
the exception of src/other/URToolkit, src/other/libtermlib, src/other/ 
libutahrle, src/other/step (where fedex_main.c lives), and src/other/ 
tkhtml.  That's just for your information.

> I like to do instead this:
>
>       fprintf(stderr,
>                 "and <object_type> is one or more of:\n"
>                 "     e       entity\n"
>                 "     p       procedure\n"
>                 "     r       rule\n"
>                 "     f       function\n"
>                 "     t       type\n"
>                 "     s       schema or file\n"
>                 "     #       pass #\n"
>                 "     E       everything (all of the above)\n"
>                 );
>
> I believe it's easier to read (and it saves several function calls).
>
> Is that type of change acceptable?

I agree!  It is easier to read and has less overhead, but C90 does  
not allow string literals longer than 509 characters.  So not all  
cases can be condensed.  If fact, most of our usage statements are  
MUCH longer, so they're broken up into blocks or even one per line  
for consistency.

Function call overhead and performance in general isn't really a  
concern since we're already making an expensive I/O call and it's  
usually as the application is exiting.  Feel free to update them if  
a) it's our code to manage, b) they're shorter than 509, and c) to  
not be stored in global variables (static or otherwise).  :-)

Cheers!
Sean

p.s. Note that printf("one\n"  "two\n"  "three\n"); is the same  
length string literal to the compiler as printf("one\ntwo\nthree\n");  
even though it's broken up.


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to