Difference between revisions of "Talk:Optimizing Plugins (AMX Mod X Scripting)"

From AlliedModders Wiki
Jump to: navigation, search
m
Line 1: Line 1:
 
Regarding [[User:NiLuJe|NiLuJe]]'s change of '\0' to 0: while they are both the same, keeping the syntax in terms of characters would probably be better for people to understand when dealing with strings, so I reverted the changes back.
 
Regarding [[User:NiLuJe|NiLuJe]]'s change of '\0' to 0: while they are both the same, keeping the syntax in terms of characters would probably be better for people to understand when dealing with strings, so I reverted the changes back.
 
:Perhaps it should be changed to '^0'... by default we don't use \ for a backtick.  This is probably what he meant to correct. -- [[User:BAILOPAN|BAILOPAN]] 18:55, 1 March 2006 (EST)
 
:Perhaps it should be changed to '^0'... by default we don't use \ for a backtick.  This is probably what he meant to correct. -- [[User:BAILOPAN|BAILOPAN]] 18:55, 1 March 2006 (EST)
 +
::Ah, indeed, fixing that now --[[User:CyberMind|cybermind]] 02:39, 2 March 2006 (EST)
 
----
 
----
  

Revision as of 02:39, 2 March 2006

Regarding NiLuJe's change of '\0' to 0: while they are both the same, keeping the syntax in terms of characters would probably be better for people to understand when dealing with strings, so I reverted the changes back.

Perhaps it should be changed to '^0'... by default we don't use \ for a backtick. This is probably what he meant to correct. -- BAILOPAN 18:55, 1 March 2006 (EST)
Ah, indeed, fixing that now --cybermind 02:39, 2 March 2006 (EST)

Is there evidence that when something is const it's faster? I think this might be to the contrary, as the compiler has to copy it into the heap first to ensure that it isn't modified. -- BAILOPAN 00:54, 1 February 2006 (EST)

Whether or not const variables/arrays are copied to the heap depends on the situation:
For a function that has an array argument with a default value, the compiler allocates space for
the default array value on the heap. However, if the array argument (with a default value) is
also const, the pawn compiler passes the default array directly (there is no need to make a copy
on the heap here, as the function will not attempt to change the array argument and, thereby,
overwrite the default value).
The arguments of a function that has "variable arguments" (denoted with the ... operator, see
the pawn booklet "The Language") are always passed by reference. For constants and expressions
that are not lvalues, the compiler copies the values to a cell that is allocated from the heap,
and it passes the address of the cell to the function.
-Page 106 (PDF page 108) of "The Implentor's Guide"
Function insert copies in the other direction and it does not change its function argument item.
In such a case, it is advised to mark the function argument as "const". This helps the pawn parser
to both check for errors and to generate better (more compact, quicker) code.
-Page 21 (PDF page 23) of "The Language Guide"
--cybermind 01:24, 1 February 2006 (EST)


I see, thanks for the clarification. Twilight, I'd amend your part somewhat to mirror that. -- BAILOPAN 02:54, 1 February 2006 (EST)