• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Scriptlistener code duplicate lines and duplicate variable

Engaged ,
Jul 14, 2022 Jul 14, 2022

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'.

TOPICS
Actions and scripting

Views

132

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advocate ,
Jul 14, 2022 Jul 14, 2022

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... 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines