AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   format or formatex. (https://forums.alliedmods.net/showthread.php?t=86776)

xbatista 03-02-2009 11:37

format or formatex.
 
What is better to use? :|

Spunky 03-02-2009 11:43

Re: format or formatex.
 
Depends on your usage.

formatex doesn't have a copyback check, so you can't do:

Code:
formatex(szString, 91, "%s/%s", szString, szName)

xbatista 03-02-2009 11:51

Re: format or formatex.
 
Hmmm... thanks.

Arkshine 03-02-2009 11:51

Re: format or formatex.
 
Wiki says :

Quote:

As of AMX Mod X 1.70, there is an ultra high-speed version of format() called formatex(). It skips copy-back checking, unlike format(). formatex() cannot be used if a source input is the same as the output buffer. For example, these are invalid:
Code:
new buffer[255] formatex(buffer, 254, "%s", buffer); formatex(buffer, 254, buffer); formatex(buffer, 254, "%d %s", buffer[2]);
It should be noted that format() will behave the same as formatex() if it detects that there will be no copy-back needed. However, formatex() does not check this, and thus is slightly faster for situations where the coder is sure of its usage.

joaquimandrade 03-06-2009 16:11

Re: format or formatex.
 
Quote:

Originally Posted by arkshine (Post 772378)
Wiki says :

By the way,

I'm missing something:

__

there is an ultra high-speed version of format() called formatex()

It should be noted that will behave the same as if it detects that there will be no copy-back needed. However, formatex() does not check this, and thus is slightly faster for situations where the coder is sure of its usage.

__

So: it doesn't work if there is copy-back needed, and is only slightly faster if there isn't. So when it is ultra faster?

ConnorMcLeod 03-06-2009 16:17

Re: format or formatex.
 
It's ultra-faster than if you use amxx1.60 for example.
When format native wasn't checking if a copy-back wasn't needed.

Of formatex is ultra faster than format with a copy-back, but in that case you couldn't use formatex.

joaquimandrade 03-06-2009 16:18

Re: format or formatex.
 
Quote:

Originally Posted by ConnorMcLeod (Post 775380)
It's ultra-faster than if you use amxx1.60 for example.
When format native wasn't checking if a copy-back wasn't needed.

Of formatex is ultra faster than format with a copy-back, but in that case you couldn't use formatex.

I think that you are not understanding or maybe its me.

If there is no copyback needed it will be slightly faster, if there is it will not work. So it is never ultrafaster.

ConnorMcLeod 03-06-2009 16:20

Re: format or formatex.
 
It's ultralower when you are forced to use format because you need a copy-back.

joaquimandrade 03-06-2009 16:23

Re: format or formatex.
 
Quote:

Originally Posted by ConnorMcLeod (Post 775386)
It's ultralower when you are forced to use format because you need a copy-back.

But that don't qualify formatex as ultrafaster since it doesn't even work in that situation.

ConnorMcLeod 03-06-2009 16:33

Re: format or formatex.
 
So, the answer is never, it's only a new native since 1.70


All times are GMT -4. The time now is 17:00.

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