Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
|
01-05-2006 18:52
Greets,
Was looking for some advice or pointers here. When coding a script, does anyone know what the 'rules' are with regards to what 'source code' characters affect the size of the 'object code' compiled to?
Let me explain a little better. If I have a set of scripts that already utilize link-messages and such to split them up or what not, but I need to code as efficiently as possible so that the source code 'scrunches' down into the object code as efficiently as possible.
What I'm wondering about is what the 'rules' are with regards to which characters effect the final amount of memory taken up by the code itself, and which characters won't matter whether you include or delete.
For instance...if you have:
Function Name() { if (condition) { instruction 1; instruction 2; instruction 3; } else { instruction 4; instruction 5; } }
And....
Function Name() { if (condition) {instruction 1; instruction 2; instruction 3;} else {instruction 4; instruction 5;} }
Will the 'more concise' version at the bottom take less memory? Or are the characters that are 'left out' in order to make it more concise not taken into account by the interpreter anyway?
Thanks!
|
Fenrir Reitveld
Crazy? Don't mind if I do
Join date: 20 Apr 2005
Posts: 459
|
01-05-2006 19:02
AFAIK, white spaces and so on won't affect the final, compiled code size. I've heard of folks getting parsing errors, so I suppose there is a maximum size of the text that you can input in the editor before it gets wonky -- but I've never encountered it.
Arrangement of the statements and how they get compiled is a different matter. There are more efficient statements, in terms of the number of virtual CPU opcodes used. (I remember someone mentioning that while statements were more efficient than for-loops.) Your example would result in the same number of op-codes emitted by the compiler, from what I understand how the compiler works.
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
01-05-2006 19:21
From: someone Will the 'more concise' version at the bottom take less memory? No, it won't make any difference whatsoever. All it'll do is make the code harder to read, which will create more work for you when you need to go fix a bug in there. Don't worry about it, write code the way you feel comfortable reading it. Spaces/tabs/newlines make no difference to the compiler. Also, personally I don't worry about the performance difference between ++i and i++, or while vs. for, or other things like that. If that becomes a make-or-break issue in my script, my opinion is that I have much bigger design problems somewhere else, and need to rethink the whole thing  I believe it's more important to write code in a manner that feels logical to me, so that when I come back to it months later, I won't be scratching my head wondering what I was trying to do there. Of course, that's just my opinion, others will probably disagree 
|
Alondria LeFay
Registered User
Join date: 2 May 2003
Posts: 725
|
01-06-2006 06:06
Indeed this is correct at this point. It was not necessarily always true (once upon a time the length of a variable name had barring). Also, the size that a script source has been increased a few versions back so I doubt unless you are into overly excessive comments you will max out the source code window before you max out run-time memory. I believe (I could be incorrect) it has been changed to 32k for source code (it is the same as notecards now).
The time difference between ++i and i++ and while and for are fairly minor however if your developing something that could potentially interate across these commands a large quantity of times, you might want to keep the "faster" call in mind. But for most scripts, I doubt the difference would be noticed.
|
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
|
01-07-2006 00:53
for memory try to do this:
integer true = TRUE; integer false = FALSE; key null = NULL_KEY etc....
and only use these instead of their LSL equivalent, on long sripts it save some bits dunno why
_____________________
 tired of XStreetSL? try those! apez http://tinyurl.com/yfm9d5b metalife http://tinyurl.com/yzm3yvw metaverse exchange http://tinyurl.com/yzh7j4a slapt http://tinyurl.com/yfqah9u
|