[KSS-checkins] r43358 - kukit/kukit.js/branch/ree-stripout-comments/kukit
reebalazs at codespeak.net
reebalazs at codespeak.net
Mon May 14 13:40:05 CEST 2007
Author: reebalazs
Date: Mon May 14 13:40:05 2007
New Revision: 43358
Modified:
kukit/kukit.js/branch/ree-stripout-comments/kukit/oper.js
Log:
Add a hasExecuteActions to oper, this can be used to speedup the binding
dquote> when there are no actions to execute
Modified: kukit/kukit.js/branch/ree-stripout-comments/kukit/oper.js
==============================================================================
--- kukit/kukit.js/branch/ree-stripout-comments/kukit/oper.js (original)
+++ kukit/kukit.js/branch/ree-stripout-comments/kukit/oper.js Mon May 14 13:40:05 2007
@@ -208,6 +208,27 @@
return this.eventrule.kss_selector.namespace;
};
+kukit.op.Oper.prototype.hasExecuteActions = function () {
+ // Decide if there are any actions (or a default action)
+ // to execute. This can speed up execution if in case
+ // we have nothing to do, there is no reason to bind
+ // the actions hook.
+ if (this.eventrule) {
+ // if it has actions, the answer is yes
+ if (this.eventrule.actions.hasActions())
+ return true
+ // if we have a default action, we will return true in any case
+ // because we may want to call it.
+ // The reason for this check is, that a default action is also
+ // valid, even if it received no parameters in the eventrule,
+ // in which case it is not present as an action.
+ var methodname = kukit.eventsGlobalRegistry.get(this.getEventNamespace(),
+ this.getEventName()).defaultactionmethodname;
+ return (typeof methodname != 'undefined');
+ } else
+ return false;
+};
+
kukit.op.Oper.prototype.makeExecuteActionsHook = function (filter) {
// Factory that creates the function that executes the actions.
// The function may take a dict that is updated on the oper
@@ -215,6 +236,11 @@
// the event will only be triggered if the filter returned true.
// THe return value of func_to_bind will show if the event
// has executed or not.
+ //
+ // Speedup.
+ if (! this.hasExecuteActions()) {
+ return function() {};
+ }
var eventname = this.getEventName();
var self = this;
var func_to_bind = function(dict) {
More information about the Kukit-checkins
mailing list