From c4c9d2a5d5b433f1e6f46e290487bb5685bdb560 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Thu, 11 Jan 2007 03:29:15 +0000 Subject: [PATCH] #108363: Faster tag parsing (preg_match to strpos). --- modules/taxonomy/taxonomy.module | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 45876d79420..1d713145e96 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -685,8 +685,8 @@ function taxonomy_form_alter($form_id, &$form) { if ($term->vid == $vocabulary->vid) { // Commas and quotes in terms are special cases, so encode 'em. - if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) { - $term->name = '"'.preg_replace('/"/', '""', $term->name).'"'; + if (strpos($term->name, ',') !== FALSE || strpos($term->name, '"') !== FALSE) { + $term->name = '"'.str_replace('"', '""', $term->name).'"'; } $typed_terms[] = $term->name; @@ -1480,8 +1480,8 @@ function taxonomy_autocomplete($vid, $string = '') { while ($tag = db_fetch_object($result)) { $n = $tag->name; // Commas and quotes in terms are special cases, so encode 'em. - if (preg_match('/,/', $tag->name) || preg_match('/"/', $tag->name)) { - $n = '"'. preg_replace('/"/', '""', $tag->name) .'"'; + if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) { + $n = '"'. str_replace('"', '""', $tag->name) .'"'; } $matches[$prefix . $n] = check_plain($tag->name); }