svn: /phd/trunk/ phpdotnet/phd/Reader/Partial.php render.php
| From: | Hannes Magnusson | Date: | Sun, 24 Apr 2011 09:58:39 +0000 |
| Subject: | svn: /phd/trunk/ phpdotnet/phd/Reader/Partial.php render.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-7998@lists.php.net to get a copy of this message | ||
bjori Sun, 24 Apr 2011 09:58:39 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=310453
Log:
Only index the stuff within the partial scope
# This takes rendering book.mysqli down to 7seconds (including indexing)
Changed paths:
U phd/trunk/phpdotnet/phd/Reader/Partial.php
U phd/trunk/render.php
Modified: phd/trunk/phpdotnet/phd/Reader/Partial.php
===================================================================
--- phd/trunk/phpdotnet/phd/Reader/Partial.php 2011-04-24 09:46:14 UTC (rev 310452)
+++ phd/trunk/phpdotnet/phd/Reader/Partial.php 2011-04-24 09:58:39 UTC (rev 310453)
@@ -29,19 +29,22 @@
} else {
throw new \Exception("Didn't get any IDs to seek");
}
- $sqlite = new \SQLite3(Config::output_dir() . "index.sqlite");
+ $parents = array();
+ if (file_exists(Config::output_dir() . "index.sqlite")) {
+ $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);
+ // 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;
@@ -109,7 +112,9 @@
} elseif (empty($this->partial)) {
return false;
} else {
- if ($id) {
+ // If we are used by the indexer then we have no clue about the
+ // parents :)
+ if ($id && $this->parents) {
// If this id isn't one of our ancestors we can jump
// completely over it
if (!in_array($id, $this->parents)) {
Modified: phd/trunk/render.php
===================================================================
--- phd/trunk/render.php 2011-04-24 09:46:14 UTC (rev 310452)
+++ phd/trunk/render.php 2011-04-24 09:58:39 UTC (rev 310453)
@@ -58,9 +58,23 @@
exit(0);
}
+function make_reader() {
+ //Partial Rendering
+ $idlist = Config::render_ids() + Config::skip_ids();
+ if (!empty($idlist)) {
+ v("Running partial build", VERBOSE_RENDER_STYLE);
+ $reader = new Reader_Partial();
+ } else {
+ v("Running full build", VERBOSE_RENDER_STYLE);
+ $reader = new Reader();
+ }
+ return $reader;
+}
+
$render = new Render();
-$reader = new Reader();
+$reader = make_reader();
+
// Set reader LIBXML options
$readerOpts = 0;
if (Config::process_xincludes()) {
@@ -83,15 +97,6 @@
v("Skipping indexing", VERBOSE_INDEXING);
}
-//Partial Rendering
-$idlist = Config::render_ids() + Config::skip_ids();
-if (!empty($idlist)) {
- v("Running partial build", VERBOSE_RENDER_STYLE);
- $reader = new Reader_Partial();
-} else {
- v("Running full build", VERBOSE_RENDER_STYLE);
-}
-
foreach((array)Config::package() as $package) {
$factory = Format_Factory::createFactory($package);
@@ -107,6 +112,7 @@
}
// Render formats
+$reader = make_reader();
$reader->open(Config::xml_file(), NULL, $readerOpts);
foreach($render as $format) {
$format->notify(Render::VERBOSE, true);