[Sie-announce] SIEコード [1499] chsetの最適化

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 12月 24日 (木) 22:57:31 JST


Revision: 1499
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1499
Author:   dhrname
Date:     2009-12-24 22:57:31 +0900 (Thu, 24 Dec 2009)

Log Message:
-----------
chsetの最適化

Modified Paths:
--------------
    branches/05x/057/sie.js

Modified: branches/05x/057/sie.js
===================================================================
--- branches/05x/057/sie.js	2009-12-24 12:45:47 UTC (rev 1498)
+++ branches/05x/057/sie.js	2009-12-24 13:57:31 UTC (rev 1499)
@@ -167,7 +167,9 @@
   var sw = this.swi.value, sh = this.shi.value;
   this.getObject("USE", STUseElement, "use", sw, sh); //use要素を先に処理
   var mat = this.vi.set(sw, sh, ob); //返り値はMatrix型
+  var sed = new Date();
   this.chset(this.rootElement, mat, sw, sh);
+  alert((new Date()).getTime() - sed.getTime());
   } catch(n) {stlog.add(n,109);}
 };
 SVGtoVML.prototype.getObject = function stvgetob( /*string*/ tag, /*object*/ st, /*string*/nodes, /*float*/w, h) {
@@ -244,8 +246,15 @@
 };
 
 //chset childNodesで要素を作成していく
+(function() {
+  var isGroup = {
+    group : 1
+  },
+  isShape = {
+    shape : 1
+  };
 SVGtoVML.prototype.chset = function _s_chset( /*element*/ ele, /*Matrix*/ matrix, /*float*/w, /*float*/h){
-  var nods = ele.childNodes, s = null;
+  var nods = ele.childNodes, s = null, _isGroup = isGroup, _isShape = isShape;
   var name = "group|shape|defs|STOP|fill|stroke|DIV|SPAN|A|image|rect|USE|FONTFACEURI|set", gname = "DIV|group"; //要素名に合致させる文字列
   var cmatrix = matrix; //子要素に継がせるCTM
   var te = nods[0];
@@ -259,7 +268,7 @@
       te = ns;
     } else {
       if (te.nodeType === 1) { //要素ならば
-        if (te.nodeName === "shape") {
+        if (isShape[te.nodeName]) {
           switch (te.getAttribute("tag")) {
             case "path":
               s = new STPath(te, matrix);
@@ -285,7 +294,7 @@
           }
         } else if (te.nodeName === "DIV") {
           s = new STText(te, matrix, w, h);
-        } else if (te.nodeName === "group") {
+        } else if (_isGroup[te.nodeName]) {
           s = new STGroupElement(te, matrix, w, h);
         } else if (te.nodeName === "A") {
           s = new STAElement(te, matrix);
@@ -310,6 +319,7 @@
   }
   nods = name = gname = matrix = cmatrix = w = h = null;
 };
+})();
 
 //object要素とembed要素の取得を総括して行う
 function Objectembeds(){




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