Copy link to clipboard
Copied
I noticed that switching from art layers to established layer mask that ScriptListner duplicates a variable
// =======================================================
var idslct = charIDToTypeID( "slct" );
var desc63 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref18 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idMsk = charIDToTypeID( "Msk " );
ref18.putEnumerated( idChnl, idChnl, idMsk );
desc63.putReference( idnull, ref18 );
var idMkVs = charIDToTypeID( "MkVs" );
desc63.putBoolean( idMkVs, false );
executeAction( idslct, desc63, DialogModes.NO );
The line "var idChnl = charIDToTypeID( "Chnl" );" is created twice.
Just sayin'.
Copy link to clipboard
Copied
I've noticed that a few days ago too. I wouldn't bet money it's necessarily wrong though, but it looks that way.
Maybe this is why actions and scripts are always getting slower... 😉
Copy link to clipboard
Copied
This is just result of interpreting the 'select' event by ScriptListner plugin. It receives the event object and parses its arguments sequentially, without thinking whether the resulting code is optimal or not.
In that case .putEnumerated() function takes three arguments - the class of the object, the type of the enumeration, and the value. That is, despite the fact that the object class and the enumeration type in this case have the same name, they actually describe different things. It seems logical to me that ScriptListner chose to represent them as separate variables.
We can optimize this code manually or use the script from the link given by @c.pfaffenbichler
The time spent on creating variables and getting a type value by name (using charIDToTypeID or stringIDToTypeID) is incomparably small in time with the executeAction function, so no, this does not affect the speed of scripts or actions in any way.
Copy link to clipboard
Copied
Have you seen this thread?
https://community.adobe.com/t5/photoshop-ecosystem-discussions/clean-sl/td-p/9358420