svn: /phd/trunk/phpdotnet/phd/Reader/ Partial.php
| From: | Hannes Magnusson | Date: | Sun, 24 Apr 2011 08:25:29 +0000 |
| Subject: | svn: /phd/trunk/phpdotnet/phd/Reader/ Partial.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-7994@lists.php.net to get a copy of this message | ||
bjori Sun, 24 Apr 2011 08:25:29 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=310450
Log:
shave off few seconds when seeking for an chunk to render
Changed paths:
U phd/trunk/phpdotnet/phd/Reader/Partial.php
Modified: phd/trunk/phpdotnet/phd/Reader/Partial.php
===================================================================
--- phd/trunk/phpdotnet/phd/Reader/Partial.php 2011-04-24 07:11:34 UTC (rev 310449)
+++ phd/trunk/phpdotnet/phd/Reader/Partial.php 2011-04-24 08:25:29 UTC (rev 310450)
@@ -6,6 +6,7 @@
{
protected $partial = array();
protected $skip = array();
+ protected $parents = array();
public function __construct() {
parent::__construct();
@@ -28,6 +29,22 @@
} else {
throw new \Exception("Didn't get any IDs to seek");
}
+ $sqlite = new \SQLite3(Config::output_dir() . "index.sqlite");
+
+ // Fetch all ancestors of the ids we should render
+ foreach($render_ids as $p => $v) {
+ do {
+ $id = $sqlite->escapeString($p);
+ $row = $sqlite->query("SELECT parent_id FROM ids WHERE docbook_id =
'$id'")->fetchArray(SQLITE3_ASSOC);
+ if ($row["parent_id"]) {
+ $parents[] = $p = $row["parent_id"];
+ continue;
+ }
+ break;
+ } while(1);
+ }
+
+ $this->parents = $parents;
}
public function read() {
@@ -92,6 +109,13 @@
} elseif (empty($this->partial)) {
return false;
} else {
+ if ($id) {
+ // If this id isn't one of our ancestors we can jump
+ // completely over it
+ if (!in_array($id, $this->parents)) {
+ parent::next();
+ }
+ }
$ignore = true;
}
}