#6

Quote:
Originally Posted by Marricio
Посмотреть сообщение
That's not the best solution, it isn't recommended to use sscanf when you're handling a single parameter. To solve the OP issue, you need to start to address the variable as an integer. (using strval())
Not really.
Do a small test, you'd notice that sscanf (the plugin, not the pawn version) is actually faster than strval.
Also, in that situation, you'd have to use isnull, which also slows it down.
Which means sscanf is the better option:

PHP код:
new val1val2times 10000000str[] = "543";
new 
tick1 GetTickCount();
for (new 
0timesi++)
{
    if (
isnull(str)) continue;
    
val1 strval(str);
}
new 
tick2 GetTickCount();
for (new 
0timesi++)
{
    if (
sscanf(str"i"val2)) continue;
}
new 
tick3 GetTickCount();
printf("strval: %i\nsscanf: %i"tick2 tick1tick3 tick2);
printf("val1: %i\nval2: %i"val1val2);
-------- 
Results:
strval1954
sscanf
1554
strval
1935
sscanf
1561
strval
1930
sscanf
1543 
Reply


Messages In This Thread
Help - by Zorono - 23.08.2016, 18:59
Re: Help - by K0P - 23.08.2016, 19:03
Re: Help - by Stinged - 23.08.2016, 19:34
Re: Help - by Marricio - 23.08.2016, 20:11
Re: Help - by Zorono - 23.08.2016, 20:19
Re: Help - by Stinged - 23.08.2016, 20:21

Forum Jump:


Users browsing this thread: 4 Guest(s)