After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696547 - Seed.js is opened and parsed each time seed_handle_closure() is called
Seed.js is opened and parsed each time seed_handle_closure() is called
Status: RESOLVED FIXED
Product: seed
Classification: Bindings
Component: libseed
git master
Other Linux
: Normal normal
: ---
Assigned To: seed-maint
seed-maint
Depends on:
Blocks:
 
 
Reported: 2013-03-25 11:18 UTC by Guillaume Desmottes
Modified: 2013-03-29 13:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test script (508 bytes, application/javascript)
2013-03-25 11:18 UTC, Guillaume Desmottes
  Details
seed_prepare_global_context: don't include Seed.js if not needed (1.36 KB, patch)
2013-03-25 12:45 UTC, Guillaume Desmottes
none Details | Review

Description Guillaume Desmottes 2013-03-25 11:18:57 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?
Comment 1 Alan Knowles 2013-03-25 12:30:16 UTC
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);
Comment 2 Guillaume Desmottes 2013-03-25 12:45:50 UTC
Created attachment 239759 [details] [review]
seed_prepare_global_context: don't include Seed.js if not needed
Comment 3 Guillaume Desmottes 2013-03-25 12:47:52 UTC
Thanks, this patch does indeed fix the redundant imports.