summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2003-11-23 12:13:08 +0000
committerDries Buytaert <dries@buytaert.net>2003-11-23 12:13:08 +0000
commit875c6e3f7707439bc260d01615b24edf6506924b (patch)
treeb4bdab1dafd42860df29fd5788a57299ddc30b96
parent2fa2497744c77ed17daecb7833484e879da50216 (diff)
downloadbrdo-875c6e3f7707439bc260d01615b24edf6506924b.tar.gz
brdo-875c6e3f7707439bc260d01615b24edf6506924b.tar.bz2
- Performance improvement: avoid copying/cloning arrays. Patch #155 by anarcat.
-rw-r--r--modules/book.module7
-rw-r--r--modules/book/book.module7
2 files changed, 8 insertions, 6 deletions
diff --git a/modules/book.module b/modules/book.module
index 7482bd3eb..94f123447 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -544,9 +544,10 @@ function book_toc($parent = 0, $indent = "", $toc = array()) {
$result = db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = '1' ORDER BY b.weight, n.title");
while ($node = db_fetch_object($result)) {
- $list = $children[$node->parent] ? $children[$node->parent] : array();
- array_push($list, $node);
- $children[$node->parent] = $list;
+ if (!$children[$node->parent]) {
+ $children[$node->parent] = array();
+ }
+ array_push($children[$node->parent], $node);
}
/*
diff --git a/modules/book/book.module b/modules/book/book.module
index 7482bd3eb..94f123447 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -544,9 +544,10 @@ function book_toc($parent = 0, $indent = "", $toc = array()) {
$result = db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = '1' ORDER BY b.weight, n.title");
while ($node = db_fetch_object($result)) {
- $list = $children[$node->parent] ? $children[$node->parent] : array();
- array_push($list, $node);
- $children[$node->parent] = $list;
+ if (!$children[$node->parent]) {
+ $children[$node->parent] = array();
+ }
+ array_push($children[$node->parent], $node);
}
/*