Changeset 25

Show
Ignore:
Timestamp:
04/06/05 22:04:09 (4 years ago)
Author:
ogawa
Message:

performance fix

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • recently-pinged-on/trunk/recently-pinged-on.pl

    r1 r25  
    22#                   by Hirotaka Ogawa (http://as-is.net/blog/) 
    33# 
    4 # Release 0.10 (Jan 29, 2005) 
     4# Release 0.11 (Jan 29, 2005) 
    55# 
    66# This software is provided as-is. You may use it for commercial or  
     
    1515    require MT::Plugin; 
    1616    my $plugin = new MT::Plugin(); 
    17     $plugin->name("recently_pinged_on Plugin 0.10"); 
     17    $plugin->name("recently_pinged_on Plugin 0.11"); 
    1818    $plugin->description("Add 'recently_ping_on' option to MTEntries container"); 
    1919    $plugin->doc_link("http://as-is.net/hacks/2005/01/recently_pinged_on_plugin.html"); 
     
    4141    my $count = 0; 
    4242    while (my $tbping = $iter->()) { 
     43        my $tb_id = $tbping->tb_id; 
     44        next if exists($temp{$tb_id}); 
     45 
    4346        require MT::Trackback; 
     47        my $trackback = MT::Trackback->load($tb_id); 
     48        my $entry_id = $trackback->entry_id or next; 
     49 
    4450        require MT::Entry; 
    45         my $trackback = MT::Trackback->load($tbping->tb_id); 
    46         my $entry_id = $trackback->entry_id; 
    47         if (!exists($temp{$entry_id})) { 
    48             my $entry = MT::Entry->load($entry_id); 
    49             next if $entry->status != MT::Entry::RELEASE(); 
    50             push(@entries, MT::Entry->load($entry_id)); 
    51             $temp{$entry_id} = (); 
    52             last if ++$count == $recently_pinged_on; 
    53         } 
     51        my $entry = MT::Entry->load($entry_id); 
     52        next if $entry->status != MT::Entry::RELEASE(); 
     53 
     54        push(@entries, $entry); 
     55        last if ++$count == $recently_pinged_on; 
     56        $temp{$tb_id} = (); 
    5457    } 
    5558