svnno****@sourc*****
svnno****@sourc*****
2010年 6月 1日 (火) 23:40:05 JST
Revision: 1870 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1870 Author: dhrname Date: 2010-06-01 23:40:05 +0900 (Tue, 01 Jun 2010) Log Message: ----------- 正規表現をfunctionの外に置いて、オブジェクトの効率化を図った Modified Paths: -------------- branches/06x/061/org/w3c/dom/svg.js Modified: branches/06x/061/org/w3c/dom/svg.js =================================================================== --- branches/06x/061/org/w3c/dom/svg.js 2010-06-01 14:18:53 UTC (rev 1869) +++ branches/06x/061/org/w3c/dom/svg.js 2010-06-01 14:40:05 UTC (rev 1870) @@ -1953,6 +1953,7 @@ /*readonly SVGPathSegList*/ this.animatedNormalizedPathSegList = this.normalizedPathSegList = new SVGPathSegList(); /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber(); //以下は、d属性に変更があった場合の処理 + var ra = /\-/g, rb = /,/g, rc = /([a-yA-Y])/g, rd = /([zZ])/g, re = /,/, sgs = /\S+/g; this.addEventListener("DOMAttrModified", function(evt){ var tar = evt.target; if (evt.attrName === "d" && evt.newValue !== ""){ @@ -1966,14 +1967,14 @@ *D = [["M", 20, 30], ["L", 20 40]] */ var dd = evt.newValue - .replace(/\-/g, " -") - .replace(/,/g, " ") - .replace(/([a-yA-Y])/g, ",$1 ") - .replace(/([zZ])/g, ",$1 1") - .replace(/,/, "") + .replace(ra, " -") + .replace(rb, " ") + .replace(rc, ",$1 ") + .replace(rd, ",$1 1") + .replace(re, "") .split(","); for (var i=0, dli=dd.length;i<dli;++i) { - D[i] = dd[i].match(/\S+/g); + D[i] = dd[i].match(sgs); for (var j=1, dili=D[i].length;j<dili;++j) { D[i][j] = _parseFloat(D[i][j]); //_parseFloatは高速化のためのAlias }