From 7a48f1634982e6e34cd863d6950d21c9024c21e4 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sun, 8 Oct 2017 13:18:11 +0200 Subject: [PATCH] Optimizations to [AV]faces. Optimize IsInteger, optimize data memory usage through list item reuse, remove redundant statement. See http://lsl.project.zone/lsl/types/list#data_memory_usage for more information on reusing of list elements. See https://gist.github.com/Sei-Lisa/2250e59040a4d10c4b28998ac045fb7d for a demonstration of the mechanism as used in this patch. --- AVsitter2/Plugins/AVfaces/[AV]faces.lsl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/AVsitter2/Plugins/AVfaces/[AV]faces.lsl b/AVsitter2/Plugins/AVfaces/[AV]faces.lsl index f6b0eee..e4b0ce5 100644 --- a/AVsitter2/Plugins/AVfaces/[AV]faces.lsl +++ b/AVsitter2/Plugins/AVfaces/[AV]faces.lsl @@ -37,7 +37,8 @@ list facial_anim_list = integer IsInteger(string data) { - return llParseString2List((string)llParseString2List(data, ["8", "9"], []), ["0", "1", "2", "3", "4", "5", "6", "7"], []) == [] && data != ""; + // This should allow for leading zeros, hence the "1" + return data != "" && (string)((integer)("1" + data)) == "1" + data; } string version = "2.2"; @@ -197,9 +198,8 @@ sequence() remove_sequences(key id) { integer index; - while (~llListFindList(running_uuid, [id])) + while (~(index = llListFindList(running_uuid, [id]))) { - index = llListFindList(running_uuid, [id]); running_uuid = llDeleteSubList(running_uuid, index, index); list sequence = llParseStringKeepNulls(llList2String(anim_animsequences, llList2Integer(running_sequence_indexes, index)), ["|"], []); running_sequence_indexes = llDeleteSubList(running_sequence_indexes, index, index); @@ -416,7 +416,10 @@ default integer index = llListFindList(facial_anim_list, [llList2String(sequence, x)]); if (~index) { - sequence = llListReplaceList(sequence, [index], x, x); + // Reuse the string in facial_anim_list to save memory + sequence = llListReplaceList(sequence, + llList2List(facial_anim_list, index, index), // OSS::[index], + x, x); } } anim_triggers += [(string)notecard_section + "|" + part0];