List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:September 13 1999 9:12pm
Subject:Re: [mySQL] Switch/Case statements versus if/else
View as plain text  
In the last episode (Sep 13), d e l   d h a n o a said:
> Do switch statements run any faster than if/else statements?

Depending on your switch statement and how many cases, gcc will
optimize it to either a set if if/elses or use a lookup table.
 
> What are the pros and cons for each?  I intend to use the switch
> statement for the type of search the user wants for a search engine
> that I am creating.  It is like hotbot where the user can choose AND,
> OR and EXACT types of searches.  The switch/case format would do the
> type of search depending on the user's choice.  Would an if/else be
> more beneficial for this?

Switch values have to be constants, and can't be strings.  Efficiency
here doesn't really matter, since the majority of the time will be
spent waiting for data from mysql anyway..

> ps- why can't the mailing list admin put a [mySQL] in the subject of
> each mail?  just wondering....

Because it wastes 8 characters in the subject line of every message. 
Simply filter list posts into another folder (filter on Delivered-To:). 
This has been discussed to death before and it not likely to change.
 
-- 
	Dan Nelson
	dnelson@stripped
Thread
converting output of query into html (with tables)and ps (with tables)Bernhard Thoni13 Sep
  • Re: converting output of query into html (with tables)and ps (with tables)sasha13 Sep
Re: converting output of query into html (with tables)and ps (withtables)Bernhard Thoni13 Sep
  • Re: converting output of query into html (with tables)and ps (withtables)Paul DuBois13 Sep
    • Re: converting output of query into html (with tables)and ps (withtables)Bob Kline13 Sep
      • Re: converting output of query into html (with tables)and ps (withtables)Bob Kline13 Sep
        • Re: converting output of query into html (with tables)and ps (withtables)Paul DuBois13 Sep
          • Re: converting output of query into html (with tables)and ps (withtables)Bob Kline13 Sep
            • Re: converting output of query into html (with tables)and ps (withtables)Paul DuBois13 Sep
              • Re: converting output of query into html (with tables)and ps (withtables)Michael Widenius16 Sep
  • Re: converting output of query into html (with tables)and ps (withtables)Bob Kline13 Sep
    • [mySQL] Switch/Case statements versus if/elsed e l   d h a n o a14 Sep
      • Re: [mySQL] Switch/Case statements versus if/elseMartin Ramsch14 Sep
      • Re: [mySQL] Switch/Case statements versus if/elseDan Nelson14 Sep
Re: converting output of query into html (with tables)and ps(withtables)Richard Ellerbrock13 Sep
Re: converting output of query into html (with tables)and ps (withtables)Richard Ellerbrock13 Sep
  • Re: converting output of query into html (with tables)and ps (withtables)Paul DuBois13 Sep
Re: converting output of query into html (with tables)and ps (withtables)Richard Ellerbrock13 Sep