Help optimize this code -
Raefal - 06.09.2014
if(strlen(inputtext) <6 || strlen(inputtext) >24)
Someone can optimize this code?
Re: Help optimize this code -
IceCube! - 06.09.2014
That's checking the length of a string, thus unless your using at for something "special"... that is the most efficient way.
Re: Help optimize this code -
Cannary2048 - 06.09.2014
What do you mean optimize? btw try
pawn Код:
if (6 < strlen(inputtext) < 24)
Re: Help optimize this code -
Raefal - 06.09.2014
Quote:
Originally Posted by Cannary2048
What do you mean optimize? btw try
pawn Код:
if (6 < strlen(inputtext) < 24)
|
That's i need, sorry for my bad english thanks!
Re: Help optimize this code -
IceCube! - 06.09.2014
Quote:
Originally Posted by Cannary2048
What do you mean optimize? btw try
pawn Код:
if (6 < strlen(inputtext) < 24)
|
That wouldn't work... and IF statement is like a real life scenario?
Example: I have more "dodo"'s than you.
pawn Код:
if(IceCubeDodoCount > CannaryDodoCount)
You can't if a 3 statements like that as it's not an if your saying:
if 6 is more than string text is more than 24. What would that even return: Example
pawn Код:
if(IceCubeDodoCount > CannaryDodoCount < OtherDudeDodoCount)
Now there are 3 statements 2 checks, however... there no way you can if that statement.
Even if it did work you last operator would have to be '>' not '<' to prevent it exceeding it's return. The original code posted, is the most optimised way. However you shouldn't concentrate too much on cosmetic looks of coding or small optimisations like this. Modern compilers are likely going to poop out the same code anyway, concentrate more on code readability unless you code runs slowly.
As you progress in your journey of learning Pawn, your coding style naturally becomes better anyway. Remember, always compare an if to a real life scenario if your not sure.
Re: Help optimize this code -
Cannary2048 - 06.09.2014
Okay, thanks for explaining, m8
, of trying to help, btw I copied from wiki:
pawn Код:
new
idx = 3;
if (0 < idx < 5)
{
print("idx is greater than 0 and less than 5!");
}
Re: Help optimize this code -
IceCube! - 06.09.2014
Quote:
Originally Posted by Cannary2048
Okay, thanks for explaining, m8 , of trying to help, btw I copied from wiki:
pawn Код:
new idx = 3; if (0 < idx < 5) { print("idx is greater than 0 and less than 5!"); }
|
Okay, you've proved me wrong. I shall use this in the future... probably? +Rep for challenging me and being right! I love people that don't back down to high posters
.
Re: Help optimize this code -
JM_Millers - 06.09.2014
Omg -_-
You don't need to oprimize it
And this isn't an optimization
Re: Help optimize this code -
Threshold - 06.09.2014
Also, it should be:
pawn Код:
if(!(6 < strlen(inputtext) < 24))