Index: feeds.module
===================================================================
--- feeds.module	(revision 224)
+++ feeds.module	(working copy)
@@ -235,67 +235,71 @@ function feeds_nodeapi(&$node, $op, $for
   // Break out node processor related nodeapi functionality.
   _feeds_nodeapi_node_processor($node, $op);
 
-  if ($importer_id = feeds_get_importer_id($node->type)) {
-    switch ($op) {
-      case 'validate':
-        // On validation stage we are working with a FeedsSource object that is
-        // not tied to a nid - when creating a new node there is $node->nid at
-        // this stage.
-        $source = feeds_source($importer_id);
-
-        // If node title is empty, try to retrieve title from feed.
-        if (trim($node->title) == '') {
-          try {
-            $source->addConfig($node->feeds);
-            // @todo Too many indirections. Clean up.
-            $batch = $source->importer->fetcher->fetch($source);
-            $source->importer->parser->parse($batch, $source);
-            // Keep the title in a static cache and populate $node->title on
-            // 'presave' as node module looses any changes to $node after
-            // 'validate'.
-            if (!$last_title = $batch->getTitle()) {
-              throw new Exception();
+  // Only check for valid feeds type when there is an appropriate operation.
+  // This saves a number of queries proportional to number of feed node types.
+  if (in_array($op, array('validate', 'presave', 'insert', 'update', 'delete'))) {
+    if ($importer_id = feeds_get_importer_id($node->type)) {
+      switch ($op) {
+        case 'validate':
+          // On validation stage we are working with a FeedsSource object that is
+          // not tied to a nid - when creating a new node there is $node->nid at
+          // this stage.
+          $source = feeds_source($importer_id);
+
+          // If node title is empty, try to retrieve title from feed.
+          if (trim($node->title) == '') {
+            try {
+              $source->addConfig($node->feeds);
+              // @todo Too many indirections. Clean up.
+              $batch = $source->importer->fetcher->fetch($source);
+              $source->importer->parser->parse($batch, $source);
+              // Keep the title in a static cache and populate $node->title on
+              // 'presave' as node module looses any changes to $node after
+              // 'validate'.
+              if (!$last_title = $batch->getTitle()) {
+                throw new Exception();
+              }
+            }
+            catch (Exception $e) {
+              drupal_set_message($e->getMessage(), 'error');
+              form_set_error('title', t('Could not retrieve title from feed.'), 'error');
             }
           }
-          catch (Exception $e) {
-            drupal_set_message($e->getMessage(), 'error');
-            form_set_error('title', t('Could not retrieve title from feed.'), 'error');
-          }
-        }
 
-        // Invoke source
-        // Node module magically moved $form['feeds'] to $node->feeds :P
-        $source->configFormValidate($node->feeds);
-        break;
-      case 'presave':
-        if (!empty($last_title)) {
-          $node->title = $last_title;
-        }
-        $last_title = NULL;
-        break;
-      case 'insert':
-      case 'update':
-        // Add configuration to feed source and save.
-        $source = feeds_source($importer_id, $node->nid);
-        $source->addConfig($node->feeds);
-        $source->save();
-
-        // Refresh feed if import on create is selected and suppress_import is
-        // not set.
-        if ($op == 'insert' && feeds_importer($importer_id)->config['import_on_create'] && !isset($node->feeds['suppress_import'])) {
-          $source->import();
-        }
-        // Add import to scheduler.
-        feeds_scheduler()->add($importer_id, 'import', $node->nid);
-        // Add expiry to schedule, in case this is the first feed of this
-        // configuration.
-        feeds_scheduler()->add($importer_id, 'expire');
-        break;
-      case 'delete':
-        // Remove feed from scheduler and delete source.
-        feeds_scheduler()->remove($importer_id, 'import', $node->nid);
-        feeds_source($importer_id, $node->nid)->delete();
-        break;
+          // Invoke source
+          // Node module magically moved $form['feeds'] to $node->feeds :P
+          $source->configFormValidate($node->feeds);
+          break;
+        case 'presave':
+          if (!empty($last_title)) {
+            $node->title = $last_title;
+          }
+          $last_title = NULL;
+          break;
+        case 'insert':
+        case 'update':
+          // Add configuration to feed source and save.
+          $source = feeds_source($importer_id, $node->nid);
+          $source->addConfig($node->feeds);
+          $source->save();
+
+          // Refresh feed if import on create is selected and suppress_import is
+          // not set.
+          if ($op == 'insert' && feeds_importer($importer_id)->config['import_on_create'] && !isset($node->feeds['suppress_import'])) {
+            $source->import();
+          }
+          // Add import to scheduler.
+          feeds_scheduler()->add($importer_id, 'import', $node->nid);
+          // Add expiry to schedule, in case this is the first feed of this
+          // configuration.
+          feeds_scheduler()->add($importer_id, 'expire');
+          break;
+        case 'delete':
+          // Remove feed from scheduler and delete source.
+          feeds_scheduler()->remove($importer_id, 'import', $node->nid);
+          feeds_source($importer_id, $node->nid)->delete();
+          break;
+      }
     }
   }
 }
