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);}; } }
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,659
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
|
|
|
|
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.