home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!netnews!bandy
- From: bandy@netnews.jhuapl.edu (Mike Bandy)
- Subject: Re: a question about if and case
- Message-ID: <Bz9H6p.DrB@netnews.jhuapl.edu>
- Organization: JHU/Applied Physics Laboratory
- References: <1gi6poINN3lv@nz12.rz.uni-karlsruhe.de>
- Date: Mon, 14 Dec 1992 18:11:12 GMT
- Lines: 45
-
- "hans friedrich steffani" <GM08@DKAUNI2.BITNET> writes:
-
-
- >i have something like
-
- >int i;
-
- >if( i == 1 || i == 25 || i == 125 )
- > {
- > /* do something sophisticated */
- > }
- >if( i == 2 || i == 30 || i == 244 )
- > {
- > /* do something different */
- > }
-
- >or should i use
-
- >switch( i )
- > {
- > case 1:
- > case 25:
- > case 125:
- > /* do something sophisticated */
- > break;
-
- > case 2:
- > case 30
- > case 244:
- > /* do something different */
- > break;
-
- > default:
- > break
- > }
-
- IMHO people worry about this sort of thing too much. The important thing
- is to develop a strong *maintainable* style. The performance differences
- are insignificant, so do what you thing works best.
-
- --
-
- Mike Bandy
- bandy@aplcomm.jhuapl.edu
- Johns Hopkins University / Applied Physics Lab
-