Studio:How do I speed up scripts by caching an intermediate collection/object?
(Redirected from How do I speed up scripts by caching an intermediate collection/object?)
Jump to navigation
Jump to search
The following example re-accesses the ascript object for each node of the Files and Item() collection. This is slow and expensive:
#enable the "makereport" property for the item we just added
$subFolder->Files->Item($script_name)->{MakeReport} = "true";
#mark the script as executable or not
$subFolder->Files->Item($script_name)->{Execute} = $entry->{executable} || 'false';</tt>
A faster and better way is to reuse the object returned by the Add() method (which is the same one returned by the Item() method later). The change shown in the example below improved performance by over 50%:
my $file = $subFolder->Files->Add($script);
#enable the "makereport" property for the item we just added
$file->{MakeReport} = "true";
#mark the script as executable or not
$file->{Execute} = $entry->{executable} || 'false';