From: Pascal B. <pa...@dy...> - 2000-10-31 21:02:53
|
I did another try to make the api faster.. It seems that the setClip() method was the biggest slowdown, so I modified it slightly: DynLayer.prototype.setClip=function(clip) { if (!this.created) { this.clip=clip return } // var cc=this.getClip() // <- not really needed.. // for (var i in clip) if (clip[i]==null) clip[i]=cc[i] // <- same here var c=this.css.clip if (is.ns4) { c.top=clip[0]||0 // <- use hard-coded default values, also in IS/NS5 line below c.right=clip[1]||this.w c.bottom=clip[2]||this.h c.left=clip[3]||0 } else if (is.ie || is.ns5) this.css.clip="rect("+(clip[0]||0)+"px "+(clip[1]||this.w)+"px "+(clip[2]||this.h)+"px "+(clip[3]||0)+"px)" } Please test and see if your code initialises a little faster (slower machines should have better results) This setClip() might not be as accurate as the previous one, because I'm skipping the getClip() method completely, and simply use the defined width and height values as default (instead of any other values).. this shouldn't be a problem because setClip is always called with all 4 parameters specified (atleast from within the DynAPI itself) Which brings up the question: is there a need for default values? why not make it so that setClip() ALWAYS needs an array of 4 elements, saves a few other checks and speeds things up a bit more (talking about milli-milliseconds here :) Let me know if nothing breakes, and if it actually makes a difference in speed. Pascal Bestebroer pa...@dy... http://www.dynamic-core.net |