Difference between revisions of "LlGetListLength"

From Second Life Wiki
Jump to navigation Jump to search
Line 9: Line 9:
|constants
|constants
|examples
|examples
|helpers
|also_functions={{LSL DefineRow||[[llListStatistics]]|[[LIST_STAT_NUM_COUNT]]}}
|also_events
|also_tests
|also_articles
|notes=A faster and lighter (in bytecode) way to determine the length of a script is to do a not-equals compare with a null list. This works because the list not-equals compare returns the difference between the lengths.
|notes=A faster and lighter (in bytecode) way to determine the length of a script is to do a not-equals compare with a null list. This works because the list not-equals compare returns the difference between the lengths.
<pre>
<pre>
Line 28: Line 23:
'linden\indra\lscript\lscript_library\lscript_alloc.cpp' @ lsa_cmp_lists<br/>
'linden\indra\lscript\lscript_library\lscript_alloc.cpp' @ lsa_cmp_lists<br/>
'linden\indra\lscript\lscript_execute\lscript_execute.cpp' @ list_list_operation
'linden\indra\lscript\lscript_execute\lscript_execute.cpp' @ list_list_operation
|helpers
|also_functions=
{{LSL DefineRow||[[llListStatistics]]|[[LIST_STAT_NUM_COUNT]] – Returns the number of [[integer]]s and [[float]]s in the list}}
|also_events
|also_tests
|also_articles
|permission
|permission
|location
|location

Revision as of 20:23, 2 March 2007

Summary

Function: integer llGetListLength( list src );

Returns an integer that is the number of elements in the list src.

• list src

Examples

Notes

A faster and lighter (in bytecode) way to determine the length of a script is to do a not-equals compare with a null list. This works because the list not-equals compare returns the difference between the lengths.

list in;
integer len_in = llGetListLength(in);
integer flen_in = (in != []);
//flen_in and len_in will be the same

integer neg_len_in = -llGetListLength(in);
integer fneg_len_in = ([] != in);
//flen_in and len_in will be the same

Locations

'linden\indra\lscript\lscript_library\lscript_alloc.cpp' @ lsa_cmp_lists
'linden\indra\lscript\lscript_execute\lscript_execute.cpp' @ list_list_operation

See Also

Functions

•  llListStatistics LIST_STAT_NUM_COUNT – Returns the number of integers and floats in the list

Deep Notes

Search JIRA for related Issues

Signature

function integer llGetListLength( list src );