Commit 7703c036 authored by Romain Courteaud's avatar Romain Courteaud

Speed up acquired method.

No need to wait for async result when no acquired method is defined.
parent 350542fb
...@@ -735,9 +735,18 @@ ...@@ -735,9 +735,18 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
function acquire(child_gadget, method_name, argument_list) { function acquire(child_gadget, method_name, argument_list) {
var gadget = this, var gadget = this,
// Do not specify default __acquired_method_dict on prototype
// to prevent modifying this default value (with
// allowPublicAcquiredMethod for example)
aq_dict = gadget.__acquired_method_dict || {},
key, key,
gadget_scope; gadget_scope;
if (!aq_dict.hasOwnProperty(method_name)) {
// "aq_dynamic is not defined"
return gadget.__aq_parent(method_name, argument_list);
}
for (key in gadget.__sub_gadget_dict) { for (key in gadget.__sub_gadget_dict) {
if (gadget.__sub_gadget_dict.hasOwnProperty(key)) { if (gadget.__sub_gadget_dict.hasOwnProperty(key)) {
if (gadget.__sub_gadget_dict[key] === child_gadget) { if (gadget.__sub_gadget_dict[key] === child_gadget) {
...@@ -745,17 +754,11 @@ ...@@ -745,17 +754,11 @@
} }
} }
} }
return new RSVP.Queue() return new RSVP.Queue()
.push(function waitForAcquireMethod() { .push(function waitForAcquireMethod() {
// Do not specify default __acquired_method_dict on prototype
// to prevent modifying this default value (with
// allowPublicAcquiredMethod for example)
var aq_dict = gadget.__acquired_method_dict || {};
if (aq_dict.hasOwnProperty(method_name)) {
return aq_dict[method_name].apply(gadget, return aq_dict[method_name].apply(gadget,
[argument_list, gadget_scope]); [argument_list, gadget_scope]);
}
throw new renderJS.AcquisitionError("aq_dynamic is not defined");
}) })
.push(undefined, function handleAcquireMethodError(error) { .push(undefined, function handleAcquireMethodError(error) {
if (error instanceof renderJS.AcquisitionError) { if (error instanceof renderJS.AcquisitionError) {
...@@ -980,7 +983,10 @@ ...@@ -980,7 +983,10 @@
}); });
gadget_instance.__chan.bind("acquire", gadget_instance.__chan.bind("acquire",
function handleChannelAcquire(trans, params) { function handleChannelAcquire(trans, params) {
gadget_instance.__aq_parent.apply(gadget_instance, params) new RSVP.Queue()
.push(function () {
return gadget_instance.__aq_parent.apply(gadget_instance, params);
})
.then(trans.complete) .then(trans.complete)
.fail(function handleChannelAcquireError(e) { .fail(function handleChannelAcquireError(e) {
trans.error(e.toString()); trans.error(e.toString());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment