home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18334 < prev    next >
Encoding:
Text File  |  1992-12-14  |  1.1 KB  |  56 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!netnews!bandy
  3. From: bandy@netnews.jhuapl.edu (Mike Bandy)
  4. Subject: Re: a question about if and case
  5. Message-ID: <Bz9H6p.DrB@netnews.jhuapl.edu>
  6. Organization: JHU/Applied Physics Laboratory
  7. References: <1gi6poINN3lv@nz12.rz.uni-karlsruhe.de>
  8. Date: Mon, 14 Dec 1992 18:11:12 GMT
  9. Lines: 45
  10.  
  11. "hans friedrich steffani" <GM08@DKAUNI2.BITNET> writes:
  12.  
  13.  
  14. >i have something like
  15.  
  16. >int i;
  17.  
  18. >if( i == 1 || i == 25 || i == 125 )
  19. > {
  20. >  /* do something sophisticated */
  21. > }
  22. >if( i == 2 || i == 30 || i == 244 )
  23. > {
  24. >  /* do something different */
  25. > }
  26.  
  27. >or should i use
  28.  
  29. >switch( i )
  30. > {
  31. >  case 1:
  32. >  case 25:
  33. >  case 125:
  34. >  /* do something sophisticated */
  35. >  break;
  36.  
  37. >  case 2:
  38. >  case 30
  39. >  case 244:
  40. >  /* do something different */
  41. >  break;
  42.  
  43. >  default:
  44. >  break
  45. > }
  46.  
  47. IMHO people worry about this sort of thing too much.  The important thing
  48. is to develop a strong *maintainable* style.  The performance differences
  49. are insignificant, so do what you thing works best.
  50.  
  51. -- 
  52.  
  53.     Mike Bandy
  54.     bandy@aplcomm.jhuapl.edu
  55.     Johns Hopkins University / Applied Physics Lab
  56.