Changeset 1444


Ignore:
Timestamp:
09/23/09 12:05:58 (15 years ago)
Author:
amuller
Message:

Ticket #653 - Melhoria de performance do serialize e unserialize

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/js/connector.js

    r1443 r1444  
    121121                                                { 
    122122                                                        case 'number': 
    123                                                                 str_data += 'i:' + i + ';' + _thisObject.serialize(data[i]); 
     123                                                                str_data += 'i:' + i + ';' + f(data[i]); 
    124124                                                                break; 
    125125         
    126126                                                        case 'string': 
    127                                                                 str_data += 's:' + i.length + ':"' + i + '";' + _thisObject.serialize(data[i]); 
     127                                                                str_data += 's:' + i.length + ':"' + i + '";' + f(data[i]); 
    128128                                                                break; 
    129129         
     
    165165                } 
    166166         
    167                 var sdata = f(data); 
    168                 return sdata; 
    169         } 
    170         cConnector.prototype.matchBracket = function(strG, iniPosG) 
     167                return f(data); 
     168        } 
     169 
     170                 
     171        //Unserialize Data Method 
     172        cConnector.prototype.unserialize = function(str) 
    171173        { 
     174                 
    172175                _thisObject = this; 
    173                 var f = function (str, iniPos) 
     176                var matchB = function (str, iniPos) 
    174177                { 
    175178                        var nOpen, nClose = iniPos; 
    176                  
    177                         do  
     179                        do 
    178180                        { 
    179181                                nOpen = str.indexOf('{', nClose+1); 
     
    184186                                        return nClose; 
    185187                                } 
    186                          
    187188                                if (nOpen < nClose ) 
    188189                                { 
    189                                         nClose = _thisObject.matchBracket(str, nOpen); 
    190                                 } 
    191                          
     190                                        nClose = matchB(str, nOpen); 
     191                                } 
    192192                        } while (nOpen < nClose); 
    193193 
    194194                        return nClose; 
    195195                } 
    196  
    197                 return f(strG, iniPosG); 
    198         } 
    199          
    200                  
    201         //Unserialize Data Method 
    202         cConnector.prototype.unserialize = function(str) 
    203         { 
    204                  
    205                 _thisObject = this; 
    206196                 
    207197                var f = function (str) 
     
    221211                                                /* Process Index */ 
    222212                                                var indexStr = arrayContent.substr(pos, arrayContent.indexOf(';')+1); 
    223                                                 var index = _thisObject.unserialize(indexStr); 
     213                                                var index = f(indexStr); 
    224214                                                pos = arrayContent.indexOf(';', pos)+1; 
    225215                                                 
     
    229219                                                { 
    230220                                                        case 'a': 
    231                                                                 var pos_ = _thisObject.matchBracket(arrayContent, arrayContent.indexOf('{', pos))+1; 
     221                                                                var pos_ = matchB(arrayContent, arrayContent.indexOf('{', pos))+1; 
    232222                                                                part = arrayContent.substring(pos, pos_); 
    233223                                                                pos = pos_; 
    234                                                                 data[index] = _thisObject.unserialize(part); 
     224                                                                data[index] = f(part); 
    235225                                                                break; 
    236226                                                 
     
    245235                                                                part = arrayContent.substring(pos, arrayContent.indexOf(';', pos)+1); 
    246236                                                                pos = arrayContent.indexOf(';', pos)+1; 
    247                                                                 data[index] = _thisObject.unserialize(part); 
     237                                                                data[index] = f(part); 
    248238                                                                break; 
    249239                                                } 
Note: See TracChangeset for help on using the changeset viewer.