Some micro-optimizations.

- [AV]sitA: Compute loading progress percentage without converting to float. Remove some 'else' clauses, adding 'return' where appropriate. That required moving the retrieval of the next notecard line near the top. A block has been left indented for clarity, and will be unindented in the next commit.
- [AV]prop: Remove some 'else' clauses, adding 'return' where appropriate. A block has been left indented for clarity, and will be unindented in the next commit.
- [AV]Xcite!: Change (string)llList2Integer to llList2String, after verifying that the elements in the list are always integers, and therefore this can't cause problems.
- [AV]root-RLV-extra: Remove unused event.
- [AV]faces: Change llListReplaceList with a replacement of [] to llDeleteSubList, to save one argument. Remove unnecessary 'else'.
- [AV]sequence: Comment out unused condition. It would be removed by the optimizer anyway, but this will hopefully help with clarity.
- AVpos-shifter: Change var++ to ++var (the optimizer would also do this anyway).
This commit is contained in:
Sei Lisa 2017-08-15 18:04:45 +02:00 committed by Sei-Lisa
parent 65c067cc30
commit 7482550bef
8 changed files with 106 additions and 68 deletions

View file

@ -125,9 +125,9 @@ default
{
if (DEBUG)
{
Out(0, "Setting " + name + "'s tilt to " + (string)llList2Integer(XCITE_TILT, index));
Out(0, "Setting " + name + "'s tilt to " + llList2String(XCITE_TILT, index));
}
llMessageLinked(LINK_SET, 20020, name + "|" + (string)llList2Integer(XCITE_TILT, index), "");
llMessageLinked(LINK_SET, 20020, name + "|" + llList2String(XCITE_TILT, index), "");
}
else
{

View file

@ -162,9 +162,6 @@ default
state running
{
state_entry()
{
}
link_message(integer sender, integer num, string msg, key id)
{
if (num == 90208 || num == 90209)

View file

@ -112,9 +112,9 @@ start_sequence(integer sequence_index, key av)
{
if (llList2Key(running_uuid, wasRunning) == av)
{
running_uuid = llListReplaceList(running_uuid, [], wasRunning, wasRunning);
running_sequence_indexes = llListReplaceList(running_sequence_indexes, [], wasRunning, wasRunning);
running_pointers = llListReplaceList(running_pointers, [], wasRunning, wasRunning);
running_uuid = llDeleteSubList(running_uuid, wasRunning, wasRunning);
running_sequence_indexes = llDeleteSubList(running_sequence_indexes, wasRunning, wasRunning);
running_pointers = llDeleteSubList(running_pointers, wasRunning, wasRunning);
}
}
running_uuid += av;
@ -365,9 +365,9 @@ default
{
if (llGetInventoryKey(notecard_name) != notecard_key)
{
llResetScript();
llResetScript(); // llResetScript() never returns
}
else if (get_number_of_scripts() != llGetListLength(SITTERS))
if (get_number_of_scripts() != llGetListLength(SITTERS))
{
init_sitters();
}

View file

@ -46,10 +46,6 @@ Out(integer level, string out)
default
{
state_entry()
{
}
on_rez(integer start)
{
if (start)

View file

@ -359,8 +359,9 @@ default
remove_sitter_props_by_pose_group(given_posename);
rez_props_by_trigger(given_posename);
}
return;
}
else if (num == 90200 || num == 90220) // rez or clear prop with/without sending menu back
if (num == 90200 || num == 90220) // rez or clear prop with/without sending menu back
{
list ids = llParseStringKeepNulls(id, ["|"], []);
key sitting_av_or_sitter = (key)llList2String(ids, -1);
@ -421,6 +422,7 @@ default
llMessageLinked(LINK_THIS, 90005, "", id);
}
}
return;
}
if (num == 90101) // menu choice
{
@ -429,8 +431,9 @@ default
{
llRegionSay(comm_channel, "PROPSEARCH");
}
return;
}
else if (num == 90065) // stand up
if (num == 90065) // stand up
{
remove_props_by_sitter(msg, FALSE);
remove_worn(id);
@ -439,19 +442,22 @@ default
{
SITTERS = llListReplaceList(SITTERS, [NULL_KEY], index, index);
}
return;
}
else if (num == 90030) // swap
if (num == 90030) // swap
{
remove_props_by_sitter(msg, FALSE);
remove_props_by_sitter((string)id, FALSE);
SITTERS = llListReplaceList(SITTERS, [NULL_KEY], (integer)msg, (integer)msg);
SITTERS = llListReplaceList(SITTERS, [NULL_KEY], (integer)((string)id), (integer)((string)id));
return;
}
else if (num == 90070) // update list of sitters
if (num == 90070) // update list of sitters
{
SITTERS = llListReplaceList(SITTERS, [id], (integer)msg, (integer)msg);
return;
}
else if (num == 90171 || num == 90173) // [AV]adjuster/[AV]menu add PROP line
if (num == 90171 || num == 90173) // [AV]adjuster/[AV]menu add PROP line
{
integer sitter;
if (num == 90171) // [AV]adjuster?
@ -484,8 +490,9 @@ default
}
llSay(0, text);
llSay(0, "Position your prop and click [SAVE].");
return;
}
else if (num == 90020 && (string)id == llGetScriptName()) // dump our settings
if (num == 90020 && (string)id == llGetScriptName()) // dump our settings
{
integer i;
for (; i < llGetListLength(prop_triggers); i++)
@ -501,6 +508,7 @@ default
}
}
llMessageLinked(LINK_THIS, 90021, msg, llGetScriptName()); // notify finished dumping
return;
}
}
}
@ -561,8 +569,9 @@ default
{
Out(0, "Error, cannot find prop: " + name);
}
return;
}
else if (llList2String(data, 0) == "ATTACHED" || llList2String(data, 0) == "DETACHED" || llList2String(data, 0) == "REZ" || llList2String(data, 0) == "DEREZ")
if (llList2String(data, 0) == "ATTACHED" || llList2String(data, 0) == "DETACHED" || llList2String(data, 0) == "REZ" || llList2String(data, 0) == "DEREZ")
{
integer prop_index = (integer)llList2String(data, 1);
integer sitter = (integer)llList2String(llParseStringKeepNulls(llList2String(prop_triggers, prop_index), ["|"], []), 0);
@ -573,8 +582,9 @@ default
}
// send prop event notification
llMessageLinked(LINK_SET, 90500, llDumpList2String([llList2String(data, 0), llList2String(prop_triggers, prop_index), llList2String(prop_objects, prop_index), llList2String(llParseStringKeepNulls(llList2String(prop_groups, prop_index), ["|"], []), 1), id], "|"), sitter_key);
return;
}
else if (llList2String(data, 0) == "NAG" && HAVENTNAGGED && (!llGetAttached()))
if (llList2String(data, 0) == "NAG" && HAVENTNAGGED && (!llGetAttached()))
{
llRegionSayTo(llGetOwner(), 0, "To enable auto-attachments, please enable the experience '" + llList2String(data, 1) + "' by Code Violet in 'About Land'.");
HAVENTNAGGED = FALSE;
@ -588,9 +598,9 @@ default
if (data == EOF)
{
Out(0, (string)llGetListLength(prop_triggers) + " Props Ready, Mem=" + (string)llGetFreeMemory());
return;
}
else
{
data = llGetSubString(data, llSubStringIndex(data, "◆") + 1, -1);
data = llStringTrim(data, STRING_TRIM);
string command = llGetSubString(data, 0, llSubStringIndex(data, " ") - 1);
@ -599,7 +609,7 @@ default
{
notecard_section = (integer)llList2String(parts, 0);
}
else if (llGetSubString(command, 0, 3) == "PROP")
if (llGetSubString(command, 0, 3) == "PROP")
{
if (llGetListLength(prop_triggers) == 100)
{
@ -612,11 +622,11 @@ default
{
prop_type = 1;
}
else if (command == "PROP2")
if (command == "PROP2")
{
prop_type = 2;
}
else if (command == "PROP3")
if (command == "PROP3")
{
prop_type = 3;
}
@ -634,12 +644,11 @@ default
prop_points += llList2String(parts, 5);
}
}
else if (command == "WARN")
if (command == "WARN")
{
WARN = (integer)llList2String(parts, 0);
}
notecard_query = llGetNotecardLine(notecard_name, notecard_line += 1);
}
}
}
}

View file

@ -433,9 +433,11 @@ state running
changed(integer change)
{
/*
if (change & CHANGED_LINK)
{
}
*/
if (change & CHANGED_INVENTORY)
{
if (llGetInventoryKey(notecard_name) != notecard_key || get_number_of_scripts() != llGetListLength(SITTERS))

View file

@ -30,7 +30,7 @@ web(string say, integer force)
cache += say;
if (llStringLength(llEscapeURL(cache)) > 1024 || force)
{
webcount++;
++webcount;
llHTTPRequest(url, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded", HTTP_VERIFY_CERT, FALSE], "w=" + webkey + "&c=" + (string)webcount + "&t=" + llEscapeURL(cache));
cache = "";
}

View file

@ -642,12 +642,14 @@ default
{
llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
}
return;
}
else if (num == 90076) // 90076=old-style helper stop animating
if (num == 90076) // 90076=old-style helper stop animating
{
release_sitter(one);
return;
}
else if (num == 90030) // 90030=swap sitters
if (num == 90030) // 90030=swap sitters
{
if (one == SCRIPT_CHANNEL || two == SCRIPT_CHANNEL)
{
@ -668,28 +670,33 @@ default
set_sittarget();
SITTERS = llListReplaceList(llListReplaceList(SITTERS, [""], one, one), [""], two, two);
MY_SITTER = llList2Key(SITTERS, SCRIPT_CHANNEL);
return;
}
else if (num == 90070) // 90070=update SITTERS after permission granted
if (num == 90070) // 90070=update SITTERS after permission granted
{
if (one != SCRIPT_CHANNEL)
{
SITTERS = llListReplaceList(SITTERS, [id], one, one);
}
return;
}
if (num == 90150) // 90150=ask other AVsitA scripts to place their sittargets again
{
sittargets();
return;
}
else if (num == 90202) // 90202=security script present in root
if (num == 90202) // 90202=security script present in root
{
has_security = TRUE;
llPassTouches(has_security);
return;
}
else if (num == 90203) // 90203=texture script present in root (unused)
if (num == 90203) // 90203=texture script present in root (unused)
{
has_texture = TRUE;
return;
}
else if (num == 90298) // 90298=show SitTargets (/5 targets)
if (num == 90298) // 90298=show SitTargets (/5 targets)
{
integer target = my_sittarget;
if (llGetNumberOfPrims() == 1 && target == 1)
@ -699,27 +706,32 @@ default
llSetLinkPrimitiveParams(target, [PRIM_TEXT, (string)SET + "-" + (string)SCRIPT_CHANNEL, <1,1,0>, 1]);
llSleep(5);
llSetLinkPrimitiveParams(target, [PRIM_TEXT, "", <1,1,1>, 1]);
return;
}
else if (num == 90011) // 90011=set link camera
if (num == 90011) // 90011=set link camera
{
llSetLinkCamera(LINK_THIS, (vector)msg, (vector)((string)id));
return;
}
else if (num == 90033) // 90033=clear menu listener
if (num == 90033) // 90033=clear menu listener
{
llListenRemove(menu_handle);
return;
}
else if (id == MY_SITTER)
if (id == MY_SITTER)
{
list data = llParseStringKeepNulls(msg, ["|"], []);
if (num == 90001) // 90001=start an overlay animation
{
llStartAnimation(msg);
return;
}
else if (num == 90002) // 90002=stop an overlay animation
if (num == 90002) // 90002=stop an overlay animation
{
llStopAnimation(msg);
return;
}
else if (num == 90101) // 90101=menu option chosen
if (num == 90101) // 90101=menu option chosen
{
CONTROLLER = (key)llList2String(data, 2);
if (llList2String(data, 1) == "[ADJUST]")
@ -755,6 +767,7 @@ default
target_script = target_script % llGetListLength(SITTERS);
llMessageLinked(LINK_THIS, 90030, (string)SCRIPT_CHANNEL, (string)target_script);
}
return;
}
}
if (one == SCRIPT_CHANNEL)
@ -778,13 +791,15 @@ default
speed_index = (integer)llList2String(data, 5);
apply_current_anim((integer)llList2String(data, 4));
set_sittarget();
return;
}
else if (num == 90057) // 90057=helper moved, update position
if (num == 90057) // 90057=helper moved, update position
{
list data = llParseStringKeepNulls(id, ["|"], []);
CURRENT_POSITION = (vector)llList2String(data, 0);
CURRENT_ROTATION = (vector)llList2String(data, 1);
sit_using_prim_params();
return;
}
}
}
@ -817,7 +832,7 @@ default
first_available = j;
jump foundavailable;
}
else if (llList2Integer(GENDERS, j) == -1 && first_unassigned == -1)
if (llList2Integer(GENDERS, j) == -1 && first_unassigned == -1)
{
first_unassigned = j;
}
@ -1050,13 +1065,16 @@ default
}
llMessageLinked(LINK_THIS, 90302, (string)SCRIPT_CHANNEL, llDumpList2String([llGetListLength(SITTERS), llDumpList2String(SITTER_INFO, "<22>"), SET, MTYPE, ETYPE, SWAP, FIRST_POSENAME, BRAND, CUSTOM_TEXT, llDumpList2String(ADJUST_MENU, "<22>"), SELECT, AMENU, OLD_HELPER_METHOD, RLVDesignations, onSit], "|")); // 90302=send notecard settings to AVsitB
reused_variable = (llGetFreeMemory() - 5000) / 100;
return;
}
else
{
if (notecard_lines)
{
llSetText("Loading " + (string)((integer)((float)reused_variable / notecard_lines * 100)) + "%", <1,1,0>, 1);
llSetText("Loading " + (string)(reused_variable * 100 / notecard_lines) + "%", <1,1,0>, 1);
}
// Request next line
notecard_query = llGetNotecardLine(notecard_name, ++reused_variable);
data = llGetSubString(data, llSubStringIndex(data, "◆") + 1, -1);
data = llStringTrim(data, STRING_TRIM_HEAD);
string command = llGetSubString(data, 0, llSubStringIndex(data, " ") - 1);
@ -1090,8 +1108,9 @@ default
SITTER_INFO = llList2List(parts, 1, -1);
}
}
return;
}
else if (command == "MTYPE")
if (command == "MTYPE")
{
MTYPE = (integer)part0;
llPassTouches(FALSE);
@ -1099,68 +1118,84 @@ default
{
llPassTouches(TRUE);
}
return;
}
else if (command == "ROLES")
if (command == "ROLES")
{
RLVDesignations = (string)parts;
return;
}
else if (command == "ETYPE")
if (command == "ETYPE")
{
ETYPE = (integer)part0;
return;
}
else if (command == "SELECT")
if (command == "SELECT")
{
SELECT = (integer)part0;
return;
}
else if (command == "WARN")
if (command == "WARN")
{
WARN = (integer)part0;
return;
}
else if (command == "TEXT")
if (command == "TEXT")
{
CUSTOM_TEXT = llDumpList2String(llParseStringKeepNulls(part0, ["\\n"], []), "\n");
return;
}
else if (command == "SWAP")
if (command == "SWAP")
{
SWAP = (integer)part0;
return;
}
else if (command == "AMENU")
if (command == "AMENU")
{
AMENU = (integer)part0;
return;
}
else if (command == "HELPER")
if (command == "HELPER")
{
OLD_HELPER_METHOD = (integer)part0;
return;
}
else if (command == "SET")
if (command == "SET")
{
SET = (integer)part0;
return;
}
else if (command == "KFM")
if (command == "KFM")
{
HASKEYFRAME = (integer)part0;
return;
}
else if (command == "LROT")
if (command == "LROT")
{
REFERENCE = (integer)part0;
return;
}
else if (command == "BRAND")
if (command == "BRAND")
{
BRAND = part0;
return;
}
else if (command == "DFLT")
if (command == "DFLT")
{
DFLT = (integer)part0;
return;
}
else if (command == "ONSIT")
if (command == "ONSIT")
{
onSit = part0;
return;
}
else if (command == "ADJUST")
if (command == "ADJUST")
{
ADJUST_MENU = parts;
return;
}
else if (reading_notecard_section)
if (reading_notecard_section)
{
if (llGetSubString(data, 0, 0) == "{")
{
@ -1193,7 +1228,7 @@ default
{
part0 += "*";
}
else if (command == "POSE" || command == "SYNC")
if (command == "POSE" || command == "SYNC")
{
if (FIRST_POSENAME == "")
{
@ -1211,7 +1246,7 @@ default
FIRST_FEMALE_ANIMATION_SEQUENCE = part1;
}
}
else if (command == "BUTTON" && part1 == "")
if (command == "BUTTON" && part1 == "")
{
part1 = "90200"; // default to rez prop
}
@ -1219,10 +1254,9 @@ default
}
}
}
notecard_query = llGetNotecardLine(notecard_name, ++reused_variable);
}
}
else if (query_id == reused_key)
if (query_id == reused_key)
{
notecard_lines = (integer)data;
}