AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set Stock or Bool (https://forums.alliedmods.net/showthread.php?t=339891)

MrPickles 10-06-2022 21:32

Set Stock or Bool
 
What is better in this case?

Option 1:

PHP Code:


public SpawnEffectsid )
{
         
CreateExplosionid );
         
CreateWaveid );
}
stock CreateExplosionid )
{
        
// Effect
}
stock CreateWaveid )
{
        
// Effect


or Option 2:

PHP Code:

public SpawnEffectsid )
{
         
CreateExplosionidtrue );
}
stock CreateExplosionidbool:Wave )
{
        
// Effect

       
if(Wave)
       {
            
// Create Wave
       
}


what is faster?

bigdaddy424 10-06-2022 22:12

Re: Set Stock or Bool
 
doesnt matter thats just sick to think off

fysiks 10-07-2022 00:05

Re: Set Stock or Bool
 
  1. Those two codes don't do the same thing.
  2. You're overthinking things way too much with respect to execution speed for trivial code. Just write code that works. If it become a problem (unlikely) then you can optimize later.

MrPickles 10-07-2022 00:14

Re: Set Stock or Bool
 
Quote:

what is faster?
mm I think the example and the question were extremely clear and basic, it was only to answer either option 1 or option 2
, neither of the 2 has answered what I asked, they only gave an opinion, but not a 3-word answer

Quote:

[*]Those two codes don't do the same thing.
and yes, they do, in both, a wave and an explosion are created, only the call of 1 stock is saved, in addition to leaving an option for it

fysiks 10-07-2022 00:19

Re: Set Stock or Bool
 
There will not be any significant difference.

MrPickles 10-07-2022 00:22

Re: Set Stock or Bool
 
Quote:

Originally Posted by fysiks (Post 2790557)
There will not be any significant difference.

That it is not significant does not mean that there is a difference, there is, that is why I asked which one is faster, I do not understand what is the reason for evading the answer, one could say, "the difference is not significant but the 2 is faster" , that is all

fysiks 10-07-2022 00:34

Re: Set Stock or Bool
 
Quote:

Originally Posted by MrPickles (Post 2790558)
That it is not significant does not mean that there is a difference, there is, that is why I asked which one is faster, I do not understand what is the reason for evading the answer, one could say, "the difference is not significant but the 2 is faster" , that is all

There is absolutely no reason to care which is faster (because the difference is negligible) on even a semi-modern computer. If you're interested to know the difference between two versions of code, you may be interested in learning how to profile code yourself. There are some threads on it.

You're certainly free to dislike the answer and you can wait for another answer also.

MrPickles 10-07-2022 01:09

Re: Set Stock or Bool
 
Quote:

You're certainly free to dislike the answer and you can wait for another answer also.
Yes, I received a much more effective and faster response:

Quote:

the difference is not significant but the 2 is faster
thanks for nothing

fysiks 10-07-2022 01:45

Re: Set Stock or Bool
 
Quote:

Originally Posted by MrPickles (Post 2790561)
thanks for nothing

I gave you a valid response that even you have seen from other people here.

Natsheh 10-07-2022 07:52

Re: Set Stock or Bool
 
Use the first method, because it's more unique and flexible, if you wanted to use/call each function by itself


All times are GMT -4. The time now is 23:16.

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