Jump to content

Benefits of list typecasting vs literal list?


primerib1
 Share

Recommended Posts

Okay so I have a line of code that looks like this:

llSetLinkPrimitiveParamsFast(0, [ PRIM_TEXTURE, 0, HUD_TEXTURE, HUD_SCALE, tx_offs, (float)0 ]);

If I pump the script through LSL-PyOptimizer, it 'optimizes' that line into this:

llSetLinkPrimitiveParamsFast(0, (list)17 + 0 + ((key)"some-uuid") + <0.5, 0.5, ((float)0)> + tx_offs + ((float)0));

Ignoring the const inlining, it converts a literal list into a typecasted list plus some 'addition' operations.

Now if it's a list literal with a single element, I can kind of grasp the benefit

[some_value] => (list)some_value

But this is a long literal list with many items, so there will be lots of 'addition' operations.

Is it still beneficial to translate a list-literal-with-many-items into a list-typecast-and-lots-of-additions ?

Link to comment
Share on other sites

6 minutes ago, Wulfie Reanimator said:

It probably saves a few bytes, since PyOptimizer focuses on memory efficiency, not speed.

Hmm, good point.

I only now noticed there's a checkbox "Convert lists into additions. Transforms lists of the form [a, b, c, ...] into (list)a + b + c + ... if possible."

I think from now on I will uncheck that checkbox and do conversion from literal list to typecasted list myself when necesssary.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...