From 00f9c254d91dae8b4fb3fea3f2d3fc64a58301f5 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 14 Apr 2009 06:22:10 +0000 Subject: - Patch #422366 by jamesAn: improved static caching in database drivers. --- includes/database/mysql/schema.inc | 1 + includes/database/pgsql/schema.inc | 3 ++- includes/database/query.inc | 3 +++ includes/database/sqlite/schema.inc | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-) (limited to 'includes/database') diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc index 9290cf566..abdbd0c59 100644 --- a/includes/database/mysql/schema.inc +++ b/includes/database/mysql/schema.inc @@ -175,6 +175,7 @@ class DatabaseSchema_mysql extends DatabaseSchema { // Put :normal last so it gets preserved by array_flip. This makes // it much easier for modules (such as schema.module) to map // database types back into schema types. + // $map does not use drupal_static as its value never changes. static $map = array( 'varchar:normal' => 'VARCHAR', 'char:normal' => 'CHAR', diff --git a/includes/database/pgsql/schema.inc b/includes/database/pgsql/schema.inc index 7e6947ff7..c4dda4c03 100644 --- a/includes/database/pgsql/schema.inc +++ b/includes/database/pgsql/schema.inc @@ -213,7 +213,8 @@ class DatabaseSchema_pgsql extends DatabaseSchema { // Put :normal last so it gets preserved by array_flip. This makes // it much easier for modules (such as schema.module) to map // database types back into schema types. - $map = array( + // $map does not use drupal_static as its value never changes. + static $map = array( 'varchar:normal' => 'varchar', 'char:normal' => 'character', diff --git a/includes/database/query.inc b/includes/database/query.inc index d22c0751a..226ab5a01 100644 --- a/includes/database/query.inc +++ b/includes/database/query.inc @@ -1077,6 +1077,8 @@ class DatabaseCondition implements QueryConditionInterface, Countable { // rather than just this query. That is OK, because we only need definitive // placeholder names if we're going to use them for _alter hooks, which we // are not. The alter hook would intervene before compilation. + // $next_placeholder does not use drupal_static as it increments and should + // never be reset during a request. static $next_placeholder = 1; if ($this->changed) { @@ -1168,6 +1170,7 @@ class DatabaseCondition implements QueryConditionInterface, Countable { * The extra handling directives for the specified operator, or NULL. */ protected function mapConditionOperator($operator) { + // $specials does not use drupal_static as its value never changes. static $specials = array( 'BETWEEN' => array('delimiter' => ' AND '), 'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'), diff --git a/includes/database/sqlite/schema.inc b/includes/database/sqlite/schema.inc index 1488cbe14..3014aeb7d 100644 --- a/includes/database/sqlite/schema.inc +++ b/includes/database/sqlite/schema.inc @@ -168,7 +168,8 @@ class DatabaseSchema_sqlite extends DatabaseSchema { // Put :normal last so it gets preserved by array_flip. This makes // it much easier for modules (such as schema.module) to map // database types back into schema types. - $map = array( + // $map does not use drupal_static as its value never changes. + static $map = array( 'varchar:normal' => 'VARCHAR', 'text:tiny' => 'TEXT', -- cgit v1.2.3