Changeset 2792

Show
Ignore:
Timestamp:
07/16/08 05:44:56 (1 month ago)
Author:
bchoate
Message:

Optimize assignment of static variables.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-41/lib/MT/Util.pm

    r2788 r2792  
    3131my $Has_Weaken; 
    3232sub weaken { 
    33     $Has_Weaken = eval 'use Scalar::Util; 1' && Scalar::Util->can('weaken') ? 1 : 0 
    34         unless defined $Has_Weaken; 
     33    no warnings; 
     34    return Scalar::Util::weaken($_[0]) if $Has_Weaken; 
     35    $Has_Weaken = eval 'use Scalar::Util; 1' && Scalar::Util->can('weaken') ? 1 : 0; 
    3536    Scalar::Util::weaken($_[0]) if $Has_Weaken; 
    3637} 
     
    261262} 
    262263 
    263 use vars qw( %Languages )
     264our %Languages
    264265sub format_ts { 
    265266    my($format, $ts, $blog, $lang, $is_mail) = @_; 
     
    557558        return '' unless defined $html; 
    558559        $html =~ tr!\cM!!d; 
    559         #Encode::_utf8_on($html) if MT->instance->charset eq 'utf-8'; 
    560560        unless (defined($Have_Entities)) { 
    561561            $Have_Entities = eval 'use HTML::Entities; 1' ? 1 : 0; 
    562         } 
    563         if ($Have_Entities && !MT->config->NoHTMLEntities) { 
     562            $Have_Entities = 0 if $Have_Entities && !MT->config->NoHTMLEntities; 
     563        } 
     564        if ($Have_Entities) { 
    564565            $html = HTML::Entities::encode_entities($html); 
    565566        } else { 
     
    575576            $html =~ s!>!>!g; 
    576577        } 
    577         #Encode::_utf8_off($html) if MT->instance->charset eq 'utf-8'; 
    578         $html; 
     578        return $html; 
    579579    } 
    580580 
     
    585585        unless (defined($Have_Entities)) { 
    586586            $Have_Entities = eval 'use HTML::Entities; 1' ? 1 : 0; 
    587         } 
    588         if ($Have_Entities && !MT->config->NoHTMLEntities) { 
     587            $Have_Entities = 0 if $Have_Entities && !MT->config->NoHTMLEntities; 
     588        } 
     589        if ($Have_Entities) { 
    589590            $html = HTML::Entities::decode_entities($html); 
    590591        } else { 
     
    594595            $html =~ s!&!&!g; 
    595596        } 
    596         $html; 
     597        return $html; 
    597598    } 
    598599}