Revision: 3490
          http://vexi.svn.sourceforge.net/vexi/?rev=3490&view=rev
Author:   clrg
Date:     2009-04-26 14:19:49 +0000 (Sun, 26 Apr 2009)

Log Message:
-----------
Cleanup / optimization

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2009-04-25 
00:11:10 UTC (rev 3489)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/text/edit.t 2009-04-26 
14:19:49 UTC (rev 3490)
@@ -314,21 +314,22 @@
             // words are in different blocks
             if (cbi>sbi) {
                 // sbi
-                var b = thisbox[sbi];
-                var n = b.numchildren - swi;
-                while (--n>0) b[swi+1] = null;
+                var sB = thisbox[sbi];
+                var sN = sB.numchildren;
+                while (--sN-swi>0) sB[swi+1] = null;
                 // intervening blocks
                 while (cbi>sbi+1) {
                     thisbox[sbi+1] = null;
                     cbi--;
                 }
                 // cbi
-                b = thisbox[cbi];
-                while (cwi-->0) b[0] = null;
+                var cB = thisbox[cbi];
+                while (cwi-->0) cB[0] = null;
                 
                 // combine cBlock/sBlock
-                while (cBlock.numchildren) sBlock[sBlock.numchildren] = 
cBlock[0];
-                cBlock.thisbox = null;
+                var cN = cB.numchildren;
+                while (cN--) sB[++sN] = cB[0];
+                cB.thisbox = null;
             
             // same block, different words
             } else if (cwi>swi) {
@@ -1567,15 +1568,17 @@
             var k = 0;
             
             // special case for first line
-            for (var j=0; thisbox[0][j] != null; j++)
-                ret[++k] = thisbox[0][j].text;
+            var b = thisbox[0];
+            var n = b.numchildren;
+            for (var j=0; n>j; j++) ret[++k] = b[j].text;
             
             // build up with newlines for multiline
             if (multiline) {
-                for (var i=1; thisbox[i] != null; i++) {
+                for (var i=1; numchildren>i; i++) {
                     ret[++k] = "\n";
-                    for (var j=0; thisbox[i][j] != null; j++)
-                        ret[++k] = thisbox[i][j].text;
+                    b = thisbox[i];
+                    n = b.numchildren;
+                    for (var j=0; n>j; j++) ret[++k] = b[j].text;
                 }
             }
             // return result
@@ -1651,9 +1654,10 @@
         cascade = v;
         if (f != trapee[trapname]) {
             var n = trapee.numchildren;
-            for (var i=0; n>i; i++)
-                if (trapee[i][trapname] == f)
-                    trapee[i][trapname] = v;
+            for (var i=0; n>i; i++) {
+                var b = trapee[i];
+                if (b[trapname] == f) b[trapname] = v;
+            }
         }
     }
     
@@ -1668,7 +1672,8 @@
     static.getBlocksFromString = function(t) {
         var blocks = [];
         var bn = t.split('\n');
-        for (var i=0; bn.length>i; i++) {
+        var bl = bn.length;
+        for (var i=0; bl>i; i++) {
             if (bn[i] == "")
                 blocks[blocks.length] = "";
             else {
@@ -1693,54 +1698,60 @@
         if (b1 == -1 or b2 == -1) return;
 
         var i,j;
+        var _w1 = p[b1][w1];
         // start and finish in different blocks
         if (b2>b1) {
             // set highlight for first word
-            if (p[b1][w1]) {
-                if (c1==null) p[b1][w1].highlight = h;
-                else partialHighlight(p[b1][w1], h?c1:null, h?null:c1);
+            if (_w1) {
+                if (c1==null) _w1.highlight = h;
+                else partialHighlight(_w1, h?c1:null, h?null:c1);
             }
             // set highlight for rest of first block
-            for (j=w1+1; p[b1].numchildren>j; j++)
-                p[b1][j].highlight = h;
+            var _b1 = p[b1];
+            var _b1n = _b1.numchildren;
+            for (j=w1+1; _b1n>j; j++) _b1[j].highlight = h;
             // set highlight for intermediate blocks
-            for (i=b1+1; b2>i; i++)
-                for (j=0; p[i].numchildren>j; j++)
-                    p[i][j].highlight = h;
+            for (i=b1+1; b2>i; i++) {
+                var _pi = p[i];
+                var _pin = _pi.numchildren;
+                for (j=0; _pin>j; j++) _pi[j].highlight = h;
+            }
             // set highlight for last word
-            if (p[b2][w2]) {
-                if (c2==null) p[b2][w2].highlight = h;
-                else partialHighlight(p[b2][w2], h?null:c2, h?c2:null);
+            var _w2 = p[b2][w2];
+            if (_w2) {
+                if (c2==null) _w2.highlight = h;
+                else partialHighlight(_w2, h?null:c2, h?c2:null);
             }
             // set highlight for start of last block
-            for (j=0; w2>j; j++)
-                p[b2][j].highlight = h;
+            var _b2 = p[b2];
+            for (j=0; w2>j; j++) _b2[j].highlight = h;
         
         // start and finish in different words in the same block
         } else if (w2>w1) {
             // set highlight for first word
-            if (p[b1][w1]) {
-                if (c1==null) p[b1][w1].highlight = h;
-                else partialHighlight(p[b1][w1], h?c1:null, h?null:c1);
+            if (_w1) {
+                if (c1==null) _w1.highlight = h;
+                else partialHighlight(_w1, h?c1:null, h?null:c1);
             }
             // set highlight for last word
-            if (p[b2][w2]) {
-                if (c2==null) p[b2][w2].highlight = h;
-                else partialHighlight(p[b2][w2], h?null:c2, h?c2:null);
+            var _w2 = p[b2][w2];
+            if (_w2) {
+                if (c2==null) _w2.highlight = h;
+                else partialHighlight(_w2, h?null:c2, h?c2:null);
             }
             // set highlight for intermediate words
-            for (j=w1+1; w2>j; j++)
-                p[b1][j].highlight = h;
+            var _b1 = p[b1];
+            for (j=w1+1; w2>j; j++) _b1[j].highlight = h;
         
         // down to one word - make sure it exists
-        } else if (!p[b1][w1]) return;
+        } else if (!_w1) return;
         
         // start and finish in the same word
         else if (c1 != null or c2 != null)
-            partialHighlight(p[b1][w1], h?c1:c2, h?c2:null);
+            partialHighlight(_w1, h?c1:c2, h?c2:null);
         
         // same word, character offsets not specified
-        else p[b1][w1].highlight = h;
+        else _w1.highlight = h;
     }
     
     /** sets the highlight going backwards from *1 to *2
@@ -1754,52 +1765,59 @@
         if (b1 == -1 or b2 == -1) return;
 
         var i,j;
+        var _w1 = p[b1][w1];
         // start and finish in different blocks
         if (b1>b2) {
             // set highlight for first word
-            if (p[b1][w1]) {
-                if (c1==null) p[b1][w1].highlight = h;
-                else partialHighlight(p[b1][w1], h?null:c1, h?c1:null);
+            if (_w1) {
+                if (c1==null) _w1.highlight = h;
+                else partialHighlight(_w1, h?null:c1, h?c1:null);
             }
             // set highlight for rest of first block
-            for (j=w1-1; j>=0; j--)
-                p[b1][j].highlight = h;
+            var _b1 = p[b1];
+            for (j=w1-1; j>=0; j--) _b1[j].highlight = h;
             // set highlight for intermediate blocks
-            for (i=b1-1; i>b2; i--)
-                for (j=p[i].numchildren-1; j>=0; j--)
-                    p[i][j].highlight = h;
+            for (i=b1-1; i>b2; i--) {
+                var _pi = p[i];
+                var _pin = _pi.numchildren;
+                for (j=_pin-1; j>=0; j--) _pi[j].highlight = h;
+            }
             // set highlight for last word
-            if (p[b2][w2]) {
-                if (c2==null) p[b2][w2].highlight = h;
-                else partialHighlight(p[b2][w2], h?c2:null, h?null:c2);
+            var _w2 = p[b2][w2];
+            if (_w2) {
+                if (c2==null) _w2.highlight = h;
+                else partialHighlight(_w2, h?c2:null, h?null:c2);
             }
             // set highlight for start of last block
-            for (j=p[b2].numchildren-1; j>w2; j--)
-                p[b2][j].highlight = h;
+            var _b2 = p[b2];
+            for (j=_b2.numchildren-1; j>w2; j--) _b2[j].highlight = h;
         
         // start and finish in different words in the same block
         } else if (w1>w2) {
             // set highlight for first word
-            if (p[b1][w1])
-                if (c1==null) p[b1][w1].highlight = h;
-                else partialHighlight(p[b1][w1], h?null:c1, h?c1:null);
+            if (_w1) {
+                if (c1==null) _w1.highlight = h;
+                else partialHighlight(_w1, h?null:c1, h?c1:null);
+            }
             // set highlight for last word
-            if (p[b2][w2])
-                if (c2==null) p[b2][w2].highlight = h;
-                else partialHighlight(p[b2][w2], h?c2:null, h?null:c2);
+            var _w2 = p[b2][w2];
+            if (_w2) {
+                if (c2==null) _w2.highlight = h;
+                else partialHighlight(_w2, h?c2:null, h?null:c2);
+            }
             // set highlight for intermediate words
-            for (j=w1-1; j>w2; j--)
-                p[b1][j].highlight = h;
+            var _b1 = p[b1];
+            for (j=w1-1; j>w2; j--) _b1[j].highlight = h;
         }
         // down to one word - make sure it exists
-        else if (!p[b1][w1]) return;
+        else if (!_w1) return;
         
         // start and finish in the same word
         else if (c1 != null or c2 != null)
-            partialHighlight(p[b1][w1], h?c2:null, h?c1:c2);
+            partialHighlight(_w1, h?c2:null, h?c1:c2);
         
         // same word, character offsets not specified
-        else p[b1][w1].highlight = h;
+        else _w1.highlight = h;
     }
     
 </vexi>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to