delorie.com/archives/browse.cgi | search |
From: | sparhawk AT eunet DOT at (Gerhard Gruber) |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: fast way to do a if statement |
Date: | Sat, 26 Sep 1998 22:18:05 GMT |
Organization: | Customer of EUnet Austria |
Lines: | 51 |
Message-ID: | <3610650f.47252487@news.Austria.EU.net> |
References: | <360D5D93 DOT 499C3AED AT cdworld DOT co DOT uk> |
NNTP-Posting-Host: | e112.dynamic.vienna.at.eu.net |
Mime-Version: | 1.0 |
NNTP-Posting-Date: | 26 Sep 1998 22:20:21 GMT |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Destination: Craig Rothwell <craig AT cdworld DOT co DOT uk> From: Gruber Gerhard Group: comp.os.msdos.djgpp Date: Sat, 26 Sep 1998 22:33:08 +0100: >I have a little program I have >writen to decode something but >most of the program is taken up >with: > >if (x==1) do... >if (x==2) do... >if (x==3) do... >if (x==4) do... >if (x==5) do... switch(x) { case 1: do something break; case 2: do something break; default: do something else break; } >That goes on for about 40 lines. >Is there a way to do it quicker >that would mean less messing >about for the CPU? This is faster because usually the compiler generates a jumptable for this. Of course if the numbers start from 0 or they are subsequently you can use a jump table. -- Bye, Gerhard email: sparhawk AT eunet DOT at g DOT gruber AT sis DOT co DOT at Spelling corrections are appreciated. ICQ#: 18578771
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |