[Sie-announce] SIEコード [2313] initMutationEventメソッドがボトルネックになりやすかったので、DOMAttrModifiedイベントの発火処理を改良して、メソッドの使われる回数を減らした

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 20日 (木) 21:02:16 JST


Revision: 2313
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2313
Author:   dhrname
Date:     2011-01-20 21:02:16 +0900 (Thu, 20 Jan 2011)

Log Message:
-----------
initMutationEventメソッドがボトルネックになりやすかったので、DOMAttrModifiedイベントの発火処理を改良して、メソッドの使われる回数を減らした

Modified Paths:
--------------
    branches/06x/068/org/w3c/dom/events.js

Modified: branches/06x/068/org/w3c/dom/events.js
===================================================================
--- branches/06x/068/org/w3c/dom/events.js	2011-01-19 14:20:48 UTC (rev 2312)
+++ branches/06x/068/org/w3c/dom/events.js	2011-01-20 12:02:16 UTC (rev 2313)
@@ -312,26 +312,28 @@
 
 function MutationEvent(){
   Event.call(this);
-/*Node*/  this.relatedNode;
-/*string*/  this.prevValue;
-/*string*/  this.newValue;
-/*string*/  this.attrName;
-/*unsigned short*/  this.attrChange;
   return this;
 };
 MutationEvent.prototype = new Event();
 MutationEvent.constructor = Event;
-/*void*/  MutationEvent.prototype.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg,
+(function() {
+/*void*/  this.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg,
     /*boolean*/ cancelableArg, /*Node*/ relatedNodeArg, /*string*/ prevValueArg, /*string*/ newValueArg,
     /*string*/ attrNameArg, /*unsigned short*/ attrChangeArg) {
-  this.initEvent(typeArg, canBubbleArg, cancelableArg);
-  this.relatedNode = relatedNodeArg;
-  this.prevValue = prevValueArg;
-  this.newValue = newValueArg;
-  this.attrName = attrNameArg;
-  this.attrChange = attrChangeArg;
-  typeArg = canBubbleArg = cancelableArg = relatedNodeArg = prevValueArg = newValueArg = attrNameArg = attrChangeArg = null;
-};
+    this.initEvent(typeArg, canBubbleArg, cancelableArg);
+    this.relatedNode = relatedNodeArg;
+    this.prevValue = prevValueArg;
+    this.newValue = newValueArg;
+    this.attrName = attrNameArg;
+    this.attrChange = attrChangeArg;
+    typeArg = canBubbleArg = cancelableArg = relatedNodeArg = prevValueArg = newValueArg = attrNameArg = attrChangeArg = null;
+  };
+  /*Node*/  this.relatedNode = null;
+  /*string*/  this.prevValue = null;
+  /*string*/  this.newValue = null;
+  /*string*/  this.attrName = null;
+  /*unsigned short*/  this.attrChange = 2;
+}).apply(MutationEvent.prototype);
     // attrChangeType
 /*unsigned short*/  MutationEvent.MODIFICATION  = 1;
 /*unsigned short*/  MutationEvent.ADDITION      = 2;
@@ -353,7 +355,11 @@
   /*ここから*/
   var evt = this.ownerDocument.createEvent("MutationEvents");
   if (!s) { //ノードがなければ
-    evt.initMutationEvent("DOMAttrModified", true, false, newAttr, null, newAttr.nodeValue, newAttr.nodeName, MutationEvent.ADDITION);
+    /*initMutationEventメソッドは軽量化のため省略する*/
+    evt.initEvent("DOMAttrModified", true, false);
+    evt.relatedNode = newAttr;
+    evt.newValue = newAttr.nodeValue;
+    evt.attrName = newAttr.nodeName;
   } else {
     evt.initMutationEvent("DOMAttrModified", true, false, newAttr, s.nodeValue, newAttr.nodeValue, newAttr.nodeName, MutationEvent.MODIFICATION);
   }




Sie-announce メーリングリストの案内
Back to archive index