Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
rogers  
#1 Posted : Friday, May 15, 2009 4:47:54 AM(UTC)
rogers

Rank: Newbie

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 4

I was looking at the iuembed script and noticed you use eval statements in a few places. These are expensive and can be handled differently. I've substituted the eval statements with an alternate method. We've been using this for about 6 months without error.

Code with eval statements (starting at line 34):

if (typeof(o[props[i]])=="unknown"){
eval("o.set"+props[i]+"=function(i,v){this."+props[i]+"(i)=v;};");
eval("o.get"+props[i]+"=function(i){return this."+props[i]+"(i);};");
}
else{
eval("o.set"+props[i]+"=function(v){this."+props[i]+"=v};");
eval("o.get"+props[i]+"=function(){return this."+props[i]+"};");
}
}
if (hasPaneItemApiElements){
eval("o.setPaneItemDesign = function(Pane, Index, Value){this.PaneItemDesign(Pane, Index) = Value;};");
eval("o.getPaneItemDesign = function(Pane, Index){return this.PaneItemDesign(Pane, Index);};");
eval("o.getPaneItemSelected = function(Pane, Index){return this.PaneItemSelected(Pane, Index);};");
eval("o.setPaneItemEnabled = function(Pane, Index, Value){this.PaneItemEnabled(Pane, Index) = Value;};");
eval("o.getPaneItemEnabled = function(Pane, Index){return this.PaneItemEnabled(Pane, Index);};");
}

Alternate to eval statements:

if (typeof(o[props[i]])=="unknown"){
o['set'+props[i]] = function(i,v){this[props[i]](i)=v;};
o['get'+props[i]] = function(i){return this[props[i]](i);};
}
else{
o['set'+props[i]] = function(v){this[props[i]]=v;};
o['get'+props[i]] = function(){return this[props[i]];};
}
}
if (hasPaneItemApiElements){
o.setPaneItemDesign = function(Pane, Index, Value){this.PaneItemDesign(Pane, Index) = Value;};
o.getPaneItemDesign = function(Pane, Index){return this.PaneItemDesign(Pane, Index);};
o.getPaneItemSelected = function(Pane, Index){return this.PaneItemSelected(Pane, Index);};
o.setPaneItemEnabled = function(Pane, Index, Value){this.PaneItemEnabled(Pane, Index) = Value;};
o.getPaneItemEnabled = function(Pane, Index){return this.PaneItemEnabled(Pane, Index);};
}
}
Fedor  
#2 Posted : Friday, May 15, 2009 7:19:13 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,660

Thanks: 5 times
Was thanked: 76 time(s) in 74 post(s)
Hello,

Quote:
I was looking at the iuembed script and noticed you use eval statements in a few places. These are expensive and can be handled differently. I've substituted the eval statements with an alternate method. We've been using this for about 6 months without error.


Thank you very much for your proposal. The script was designed 5 years with old concepts in mind. In upcoming version 6.x we have got rid of eval() statements at all.
Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.