Raised This Month: $ Target: $400
 0% 

weird switches :P


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 02-08-2008 , 19:46   weird switches :P
Reply With Quote #1

switch(is_user_connected(id))
{
case 0:
{
}
case 1:
{
}
}

is this using less resources and cpu power than simple if(is_user_connected(id))?
__________________

Last edited by Voi; 02-08-2008 at 19:50.
Voi is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 02-08-2008 , 19:48   Re: weird switches :P
Reply With Quote #2

Well, for one. 'is_user_connected()' returns 1 or 0. A switch statement is completely useless.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 02-08-2008 , 19:51   Re: weird switches :P
Reply With Quote #3

sry i wanted to put 0 and 1

so now its more usefull ?
__________________
Voi is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-08-2008 , 19:57   Re: weird switches :P
Reply With Quote #4

if(is_user_connected(id))


Less code space, easier to read, less typing on your part...
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
oRNY
Member
Join Date: Feb 2008
Location: Israel
Old 02-09-2008 , 08:19   Re: weird switches :P
Reply With Quote #5

I thnk an "if" will be more effective in this case.
oRNY is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 02-09-2008 , 09:07   Re: weird switches :P
Reply With Quote #6

if statements are fine if it's 3 tier (if, elseif, else), more than 3 tier definitely recommend switch instead.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode