Question
When selecting multiple objects to call a function, is an inner loop better or an outer loop better?
For example, I select multiple objects, and then call functions that are suitable for the content of the framework.
There are two ways, which one is more efficient (more scientific)?
var d = app.activeDocument;
var item = d.selection[0];
var items = d.selection;
var sel = items;
// 00001 outer loop
for (var i = 0; i < sel.length; i++) {
frameFitToContent(sel[i])
}
function frameFitToContent(s) {
s.fit(FitOptions.FRAME_TO_CONTENT);
}
// 00002 internal circulation----
frameFitToContent(items);
function frameFitToContent(sel) {
for (var i = 0; i < sel.length; i++) {
sel[i].fit(FitOptions.FRAME_TO_CONTENT);
}
}
