home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18876 < prev    next >
Encoding:
Text File  |  1992-12-24  |  1.2 KB  |  28 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!saimiri.primate.wisc.edu!sal.wisc.edu!alan
  3. From: alan@sal.wisc.edu (Alan Watson)
  4. Subject: Re: a question about if and case
  5. Message-ID: <1992Dec24.181129.17623@sal.wisc.edu>
  6. Organization: Space Astronomy Lab, Madison WI
  7. References: <1gi6poINN3lv@nz12.rz.uni-karlsruhe.de> <1992Dec24.092119.21197@jonlab.UUCP>
  8. Date: Thu, 24 Dec 1992 18:11:29 GMT
  9. Lines: 17
  10.  
  11. In article <1992Dec24.092119.21197@jonlab.UUCP> jon@jonlab.UUCP (Jon LaBadie) writes:
  12. >In article <1gi6poINN3lv@nz12.rz.uni-karlsruhe.de> "hans friedrich steffani" <GM08@DKAUNI2.BITNET> writes:
  13. >>[Query about efficient "if-elseif-" vs switch code]
  14. >
  15. >[Discussion of the "optimal" construction based on 1986
  16. > compiler technology on an unspecified architecture.]
  17.  
  18. You should write clear, straightforward code and rely on your compiler
  19. to optimize it for you.  If your compiler cannot transform between
  20. switches and series of if-elses, then buy a better compiler.
  21.  
  22. >Change only when performance has become an issue and you note,
  23. >through profiling, that the multi-way branch is a problem.
  24.  
  25. Good advice.  Unless you are writing a byte-code interpretter, the 
  26. additional overhead of a less than optimal construction is probably
  27. negligible.
  28.