SystemFindObjectBySerial V.S. FindObjtypeInContainer()
Posted: Fri Jun 09, 2006 2:18 am
I have to find a specific item in a pc backpack. I have the pc ref, the item serial and the item objtype
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]
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