It is fast when there are 10 layers but when the numbers become 100+, you feel the difference 😕😕
I honestly have no idea how yours work, but mine is basically create 2 arrays with for then compare them to find difference. And since it is a loop, it gets slower with more layers.
I did not see the simplest way - to get the name of the 1st target layer and assign it after convert to SO.
function main() {
var s2t = stringIDToTypeID;
(tr = new ActionReference).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
tr.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
(lr = new ActionReference).putProperty(s2t('property'), n = s2t('name'));
lr.putIdentifier(s2t('layer'), executeActionGet(tr).getList(p).getReference(0).getIdentifier(s2t('layerID')));
var nm = executeActionGet(lr).getString(n)
executeAction(s2t('newPlacedLayer'), undefined, DialogModes.NO);
(r = new ActionReference()).putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("null"), r);
(d1 = new ActionDescriptor()).putString(s2t("name"), nm);
d.putObject(s2t("to"), s2t("layer"), d1);
executeAction(s2t("set"), d, DialogModes.NO);
}
app.activeDocument.suspendHistory("Smart Obj Script", "main()");