Changeset 1018

Show
Ignore:
Timestamp:
07/31/08 07:47:59 (1 month ago)
Author:
MaierMan
Message:

Optimize getIcon by referring to just the extensions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/common/internalFunctions.js

    r993 r1018  
    122122        var rv = {}; 
    123123        merge(rv, obj); 
    124         rv.prototype = this.prototype
     124        merge(rv.prototype, this.prototype)
    125125        rv.constructor = this.constructor; 
    126126        return rv; 
     
    129129        String.prototype, 
    130130        {  
    131                 trim : function() { 
     131                trim: function() { 
    132132                        return this.replace(/^\s+|\s+$/g, ''); 
    133133                }, 
    134                 removeBadChars : function() { 
     134                removeBadChars: function() { 
    135135                        return this 
    136136                                .replace(/[\n\r\v?:<>*|"]/g, '_') 
    137137                                .replace(/%(?:25)?20/g, ' '); 
    138138                }, 
    139                 addFinalSlash : function() { 
     139                addFinalSlash: function() { 
    140140                        if (this.length == 0) { 
    141141                                return SYSTEMSLASH; 
     
    147147                        return this; 
    148148                }, 
    149                 removeFinalChar : function(c) { 
     149                removeFinalChar: function(c) { 
    150150                        if (this.length == 0) { 
    151151                                return this; 
     
    156156                        return this; 
    157157                }, 
    158                 removeLeadingChar : function(c) { 
     158                removeLeadingChar: function(c) { 
    159159                        if (this.length == 0) { 
    160160                                return this; 
     
    165165                        return this; 
    166166                }, 
    167                 removeFinalSlash : function() { 
     167                removeFinalSlash: function() { 
    168168                        return this.removeFinalChar(SYSTEMSLASH); 
    169169                }, 
     
    174174                        return this.replaceSlashes(SYSTEMSLASH); 
    175175                }, 
    176                 removeLeadingSlash : function() { 
     176                removeLeadingSlash: function() { 
    177177                        return this.removeLeadingChar(SYSTEMSLASH); 
    178178                }, 
    179                 getUsableFileName : function() { 
     179                getUsableFileName: function() { 
    180180                        let t = this.replace(/\?.*$/, '') 
    181181                                .normalizeSlashes() 
     
    184184                        return t.split(SYSTEMSLASH).pop().removeBadChars().trim(); 
    185185                }, 
    186                 getExtension : function() { 
     186                getExtension: function() { 
    187187                        let name = this.getUsableFileName(); 
    188188                        let c = name.lastIndexOf('.'); 
     
    438438                        url = _atos(link); 
    439439                } 
     440                let ext = url.getExtension(); 
     441                url = 'file' + (ext ? '.' + ext : ''); 
     442                Debug.logString(url); 
    440443                return _getIcon(url, size); 
    441444        } 
     
    676679} 
    677680 
     681// XXX switch to nsITimer? 
    678682function Timer(func, interval, persist, now) { 
    679683  this._id = newUUIDString();