Assuming the pc as a standard number of items in his backpack (say 15-20 items?) and that 1 of them is the searched item and 3 of them have the same objtype of the item, which of the two codes should be the fastest?
Code: Select all
-- Code 1 --
function SearchItemInBackpack(pc, searched_serial, searched_objtype)
var searched_item := SystemFindObjectBySerial(searched_serial);
endfunction
Code: Select all
-- Code 2 --
function SearchItemInBackpack(pc, searched_serial, searched_objtype)
var searched_item;
var items := FindObjtypeInContainer(pc.backpack, searched_objtype);
foreach item in item
if(item.serial == searched_serial)
searched_item := item;
break;
endif
endforeach
endfunction