Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65096 - website/public_html/beta/common/code
From: dnljms_at_[hidden]
Date: 2010-08-29 04:53:12


Author: danieljames
Date: 2010-08-29 04:53:11 EDT (Sun, 29 Aug 2010)
New Revision: 65096
URL: http://svn.boost.org/trac/boost/changeset/65096

Log:
Faster basic_filter.
Text files modified:
   website/public_html/beta/common/code/boost_archive.php | 40 ++++++++++++----------------------------
   1 files changed, 12 insertions(+), 28 deletions(-)

Modified: website/public_html/beta/common/code/boost_archive.php
==============================================================================
--- website/public_html/beta/common/code/boost_archive.php (original)
+++ website/public_html/beta/common/code/boost_archive.php 2010-08-29 04:53:11 EDT (Sun, 29 Aug 2010)
@@ -436,40 +436,24 @@
 
 function basic_filter($params)
 {
- $text = prepare_html($params['content']);
- $text = remove_html_banner($text);
+ $text = remove_html_banner($params['content']);
 
     $is_xhtml = preg_match('@<!DOCTYPE[^>]*xhtml_at_i', $text);
     $tag_end = $is_xhtml ? '/>' : '>';
     
- $sections = preg_split('@(</head>|<body[^>]*>)@i',$text,-1,PREG_SPLIT_DELIM_CAPTURE);
-
- $body_index = 0;
- $index = 0;
- foreach($sections as $section) {
- if(stripos($section, '<body') === 0) {
- $body_index = $index;
- break;
- }
- ++$index;
- }
-
- if(!$body_index) {
- print($text);
+ $match = null;
+
+ if(preg_match('@(?:</head>\s*)?<body[^>]*>@is', $text, $match, PREG_OFFSET_CAPTURE)) {
+ echo substr($text, 0, $match[0][1]);
+ echo '<link rel="icon" href="/favicon.ico" type="image/ico"'.$tag_end;
+ echo '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"'.$tag_end;
+ echo $match[0][0];
+ virtual("/common/heading-doc.html");
+ echo prepare_html(substr($text, 0, $match[0][1] + strlen($match[0][0])));
+
     }
     else {
- $index = 0;
- foreach($sections as $section) {
- print($section);
- if($index == 0) {
- print '<link rel="icon" href="/favicon.ico" type="image/ico"'.$tag_end;
- print '<link rel="stylesheet" type="text/css" href="/style-v2/section-basic.css"'.$tag_end;
- }
- else if($index == $body_index) {
- virtual("/common/heading-doc.html");
- }
- ++$index;
- }
+ echo $text;
     }
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk