Changeset 38815 for websites

Show
Ignore:
Timestamp:
01/29/11 19:06:12 (2 years ago)
Author:
NeoCat
Message:

speed up sorting

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • websites/twicli/plugins/regexp.js

    r38805 r38815  
    2626// タブ切り替え処理 
    2727function switchRegexp(tab) { 
    28         var pickup = new Array(); 
     28        var pickup = [[],[]]; 
    2929        switchTo(tab.id); 
    3030        if (!tab.no_close) { 
     
    4444                                                if (duplication[target.tw.id_str]) continue; 
    4545                                                duplication[target.tw.id_str] = true; 
    46                                                 pickup.push(target.tw); 
     46                                                pickup[t].push(target.tw); 
    4747                                                break; 
    4848                                        } 
     
    5151                } 
    5252        } 
    53         pickup.sort(function(a,b){ return b.id - a.id }); 
    54         twShow2(pickup); 
     53        var sorted = []; 
     54        while (pickup[0].length > 0 || pickup[1].length > 0) { 
     55                if (!pickup[0][0] || pickup[1][0] && pickup[0][0].id < pickup[1][0].id) 
     56                        sorted.push(pickup[1].shift()); 
     57                else 
     58                        sorted.push(pickup[0].shift()); 
     59        } 
     60        twShow2(sorted); 
    5561        callPlugins("regexp_switched", tab); 
    5662}