From 0544d005f5afa7eabfba3629c27b4981b6d0ebdc Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 23 Jun 2002 13:42:29 +0000 Subject: - Made node_comment_mode() cache the mode when possible. Patch from Marco's sandbox. --- modules/node.module | 6 +++++- modules/node/node.module | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/node.module b/modules/node.module index f70e2173f..d575c6eb9 100644 --- a/modules/node.module +++ b/modules/node.module @@ -363,7 +363,11 @@ function node_filter_line($text) { } function node_comment_mode($nid) { - return db_result(db_query("SELECT comment FROM node WHERE nid = '%s'", $nid)); + static $comment_mode; + if (!isset($comment_mode[$nid])) { + $comment_mode[$nid] = db_result(db_query("SELECT comment FROM node WHERE nid = '%s'", $nid)); + } + return $comment_mode[$nid]; } function node_filter($text) { diff --git a/modules/node/node.module b/modules/node/node.module index f70e2173f..d575c6eb9 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -363,7 +363,11 @@ function node_filter_line($text) { } function node_comment_mode($nid) { - return db_result(db_query("SELECT comment FROM node WHERE nid = '%s'", $nid)); + static $comment_mode; + if (!isset($comment_mode[$nid])) { + $comment_mode[$nid] = db_result(db_query("SELECT comment FROM node WHERE nid = '%s'", $nid)); + } + return $comment_mode[$nid]; } function node_filter($text) { -- cgit v1.2.3