[Sie-announce] SIEコード [1500] switch構文をやめたことによる、chsetのさらなる軽量化

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 12月 24日 (木) 23:06:08 JST


Revision: 1500
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1500
Author:   dhrname
Date:     2009-12-24 23:06:08 +0900 (Thu, 24 Dec 2009)

Log Message:
-----------
switch構文をやめたことによる、chsetのさらなる軽量化

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

Modified: branches/05x/057/sie.js
===================================================================
--- branches/05x/057/sie.js	2009-12-24 13:57:31 UTC (rev 1499)
+++ branches/05x/057/sie.js	2009-12-24 14:06:08 UTC (rev 1500)
@@ -252,9 +252,18 @@
   },
   isShape = {
     shape : 1
+  },
+  STElement = {
+    "path" : STPath,
+    "rect" : STRectElement,
+    "circle" : STCircle,
+    "ellipse" : STEllipse,
+    "polyline" : STPolyline,
+    "polygon" : STPolygon,
+    "line" : STLine
   };
 SVGtoVML.prototype.chset = function _s_chset( /*element*/ ele, /*Matrix*/ matrix, /*float*/w, /*float*/h){
-  var nods = ele.childNodes, s = null, _isGroup = isGroup, _isShape = isShape;
+  var nods = ele.childNodes, s = null, _isGroup = isGroup, _isShape = isShape, _STElement = STElement;
   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];
@@ -269,29 +278,7 @@
     } else {
       if (te.nodeType === 1) { //要素ならば
         if (isShape[te.nodeName]) {
-          switch (te.getAttribute("tag")) {
-            case "path":
-              s = new STPath(te, matrix);
-            break;
-            case "rect":
-              s = new STRectElement(te, matrix, w, h);
-            break;
-            case "circle":
-              s = new STCircle(te, matrix, w, h);
-            break;
-            case "ellipse":
-              s = new STEllipse(te, matrix, w, h);
-            break;
-            case "polyline":
-              s = new STPolyline(te, matrix);
-            break;
-            case "polygon":
-              s = new STPolygon(te, matrix);
-            break;
-            case "line":
-              s = new STLine(te, matrix, w, h);
-            break;
-          }
+          s = new (_STElement[te.getAttribute("tag")])(te, matrix, w, h);
         } else if (te.nodeName === "DIV") {
           s = new STText(te, matrix, w, h);
         } else if (_isGroup[te.nodeName]) {




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