Raised This Month: $ Target: $400
 0% 

Optimizing code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 04-10-2009 , 06:13   Re: Optimizing code.
Reply With Quote #1

I think 2nd "if" can be "else if", same with 4th.
__________________
hleV is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-10-2009 , 08:35   Re: Optimizing code.
Reply With Quote #2

Quote:
Originally Posted by hleV View Post
I think 2nd "if" can be "else if", same with 4th.
You would use "else if" if the cases were mutually exclusive.
__________________
fysiks is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 04-10-2009 , 13:46   Re: Optimizing code.
Reply With Quote #3

I suspect that this could be optimized more, if I could see more of your code. I'm not sure.


Anyways, I'm not sure if this is compatible with your code. I think it will probably work:

PHP Code:
    if( equalszClassname"func_button" ) )
    {
        static 
szTarget[32];
        
peviEntitypev_targetszTarget31 );
        
        new 
iNumAssigned 0
        
        
// only if sizeof szCounterStart == sizeof szCounterStop
        
for( new 0sizeof szCounterStarti++ )
        {
            if( 
iNumAssigned == )
                break;
            
            if( 
equalszTargetszCounterStart[i] ) )
            {
                if( !
gButtons[START] )
                {
                    
gButtons[START] = iEntity;
                    
iNumAssigned++;
                }
                else
                {
                    
gButtons[START2] = iEntity;
                    
iNumAssigned++;
                }
            }
            else if( 
equalszTargetszCounterStop[i] ) )
            {
                if( !
gButtons[STOP] )
                {
                    
gButtons[STOP] = iEntity;
                    
iNumAssigned++;
                }
                else
                {
                    
gButtons[STOP2] = iEntity;
                    
iNumAssigned++;
                }
            }
        }
    } 
__________________

Last edited by stupok; 04-10-2009 at 13:57. Reason: EDIT: oops, hold on
stupok 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 02:19.


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