Thread Previous • Date Previous • Date Next • Thread Next |
On 09-09-16 01:07 PM, Sidnei da Silva wrote:
Hi Gavin, On Wed, Sep 16, 2009 at 1:44 PM, Gavin Panella <gavin.panella@xxxxxxxxxxxxx> wrote: <snip>Thankfully the fix is reasonably obvious: change the bug index page to use fewer .use(...) blocks. This will also make the page cleaner and shorter too, so it's not a nasty workaround.One thing that I've mentioned on IRC and didn't get carried over is that it is possible to save the result of the first YUI().use() into a variable and reuse that across multiple function calls. Eg: Y = YUI().use(...); some_function(Y); another_function(Y);
Calling YUI() constructs a new sandbox each and every time. That is expensive.Instead of passing around a magic context object, you can get multiple .use() statements by constructing a single sandbox instance, then calling .use() on it as many times as needed:
var I = YUI(); I.use(..., function(Y) {...});But be warned that this causes race conditions between .use() blocks in PR2: if the code in one .use() block depends on code in another, things will go funky :(
Maris
Attachment:
signature.asc
Description: OpenPGP digital signature
Thread Previous • Date Previous • Date Next • Thread Next |