GNOME Bugzilla – Bug 696547
Seed.js is opened and parsed each time seed_handle_closure() is called
Last modified: 2013-03-29 13:00:52 UTC
Created attachment 239749 [details] test script Stracing Seed while executing the attached script shows that Seed.js is opened and read each time call.invoke_async() is called. This is because seed_handle_closure() calls seed_prepare_global_context() which evaluates a 'Seed.include()' call on Seed.js. Calling seed_prepare_global_context() more than once looks suspicious. Does Seed really need to call it for each closure?
I just added this to Seed.js to check the effect. if (typeof(Seed.sprintf) == 'undefined') { print( "adding sprintf"); } else { print( "adding sprintf (it already exists"); } -- prints 'adding sprintf'... then prints (it already exists) on every callback. so your premise is correct. I suggest just adding something like JSStringRef check_sprintf = JSStringCreateWithUTF8CString ("sprintf"); if (!JSObjectHasProperty( ctx, seed_obj_ref, check_sprintf)) { .. do include... } JSStringRelease (check_sprintf);
Created attachment 239759 [details] [review] seed_prepare_global_context: don't include Seed.js if not needed
Thanks, this patch does indeed fix the redundant imports.