Raised This Month: $ Target: $400
 0% 

format or formatex.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 03-02-2009 , 11:37   format or formatex.
Reply With Quote #1

What is better to use?
xbatista is offline
Send a message via Skype™ to xbatista
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-02-2009 , 11:43   Re: format or formatex.
Reply With Quote #2

Depends on your usage.

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

Code:
formatex(szString, 91, "%s/%s", szString, szName)
Spunky is offline
Send a message via AIM to Spunky
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 03-02-2009 , 11:51   Re: format or formatex.
Reply With Quote #3

Hmmm... thanks.
xbatista is offline
Send a message via Skype™ to xbatista
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-02-2009 , 11:51   Re: format or formatex.
Reply With Quote #4

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.
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-06-2009 , 16:11   Re: format or formatex.
Reply With Quote #5

Quote:
Originally Posted by arkshine View Post
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?
__________________

Last edited by joaquimandrade; 03-06-2009 at 16:14.
joaquimandrade is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-06-2009 , 16:17   Re: format or formatex.
Reply With Quote #6

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-06-2009 , 16:18   Re: format or formatex.
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
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.
__________________
joaquimandrade is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-06-2009 , 16:20   Re: format or formatex.
Reply With Quote #8

It's ultralower when you are forced to use format because you need a copy-back.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-06-2009 , 16:23   Re: format or formatex.
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
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.
__________________
joaquimandrade is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-06-2009 , 16:33   Re: format or formatex.
Reply With Quote #10

So, the answer is never, it's only a new native since 1.70
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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