mirror of
https://github.com/php/phd.git
synced 2026-03-23 22:52:05 +01:00
Only index the stuff within the partial scope
# This takes rendering book.mysqli down to 7seconds (including indexing)
This commit is contained in:
@@ -29,19 +29,22 @@ class Reader_Partial extends Reader
|
||||
} 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 @@ class Reader_Partial extends Reader
|
||||
} 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)) {
|
||||
|
||||
26
render.php
26
render.php
@@ -58,8 +58,22 @@ if (Config::quit()) {
|
||||
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;
|
||||
@@ -83,15 +97,6 @@ if (Index::requireIndexing()) {
|
||||
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 @@ foreach((array)Config::package() as $package) {
|
||||
}
|
||||
|
||||
// Render formats
|
||||
$reader = make_reader();
|
||||
$reader->open(Config::xml_file(), NULL, $readerOpts);
|
||||
foreach($render as $format) {
|
||||
$format->notify(Render::VERBOSE, true);
|
||||
|
||||
Reference in New Issue
Block a user