Optimizations questions
PHP Code:
Example: PHP Code:
========================== Is it better to have all plugins seperated, or have a HUGE with all of them inside a single one? Does it affect performance? ========================== When doing loops: PHP Code:
Like this: PHP Code:
|
Re: Optimizations questions
The return value will depend on what you are doing. You should return the value that makes the most sense and does what you want it to do for that function. Also, PLUGIN_* return values only have meaning in certain contexts. I remember that there was a good post about the return values around here somewhere. EDIT: Here is one such thread.
There is no reason to merge plugins that do not need to merge functionality. Any efficiency gain by merging plugins for no reason will not be appreciable and will make things harder in the long run. Generally, it is good practice to separate functionality into separate plugins (this is called modularity and is an important concept in software engineering). I don't believe there is any appreciable difference with creating the counting variable in the for loop construct. The first of the three arguments is only called once. The second and third arguments of the for() are both called on every iteration. That is why you will see people remove functions from the second and third arguments (e.g. "i < get_maxplayers()" as the conditional should be avoided). |
Re: Optimizations questions
Quote:
I made this because I saw some of plugins using "return PLUGIN_HANDLED" all the time for no reason, thats why i got confuse. Same thing with loop, i saw a guy somewhere saying that "new i = 0" is called on every iteration, and it must be used outside for(), but i was not sure. |
Re: Optimizations questions
Quote:
Quote:
|
Re: Optimizations questions
Btw, why i see alot of plugins using:
PHP Code:
|
Re: Optimizations questions
It makes it easy to change the max number of players without changing any actual code. Also, it's self documenting code, it specifies that 32 of the 33 cells are for player entities. The extra 1 cell is only there to make it easier to index arrays by entity index (which is 1 based in the context of players).
|
Re: Optimizations questions
Well, if "new i = 0" was called each iteration you would be stuck in an infinite loop as the value of "i" variable would never be anything other than 0.
So, logically, it is called only once before iterating starts. |
Re: Optimizations questions
Quote:
|
Re: Optimizations questions
Quote:
All forwards return int. `return;' is probably taken as `return 0;'. Quote:
It may affect the performance when such situation (see below) is met. PHP Code:
PHP Code:
|
Re: Optimizations questions
Quote:
|
| All times are GMT -4. The time now is 18:38. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.