Development

Changeset 13869

You must first sign up to be able to contribute.

Changeset 13869

Show
Ignore:
Timestamp:
12/09/08 10:52:42 (1 year ago)
Author:
FabianLange
Message:

[1.2] applied performance patch for sfToolkit::stripComments from Wicked. Thanks for providing those well done patches. fixes #5237

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/util/sfToolkit.class.php

    r12169 r13869  
    186186    } 
    187187 
     188    $ignore = array(T_COMMENT => true, T_DOC_COMMENT => true); 
    188189    $output = ''; 
    189190 
    190     $tokens = token_get_all($source); 
    191     foreach ($tokens as $token) 
    192     { 
    193       if (is_string($token)) 
    194       { 
     191    foreach (token_get_all($source) as $token) { 
     192      // array 
     193      if (isset($token[1])) { 
     194        // no action on comments 
     195        if (!isset($ignore[$token[0]])) { 
     196          // anything else -> output "as is" 
     197          $output .= $token[1]; 
     198        } 
     199      } else { 
    195200        // simple 1-character token 
    196201        $output .= $token; 
    197       } 
    198       else 
    199       { 
    200         // token array 
    201         list($id, $text) = $token; 
    202  
    203         switch ($id) 
    204         { 
    205           case T_COMMENT: 
    206           case T_DOC_COMMENT: 
    207             // no action on comments 
    208             break; 
    209           default: 
    210             // anything else -> output "as is" 
    211             $output .= $text; 
    212             break; 
    213         } 
    214202      } 
    215203    } 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.