Add warnings. Throwing exceptions is expensive!!!
authorJan Schneider <jan@horde.org>
Wed, 22 Sep 2010 15:01:39 +0000 (17:01 +0200)
committerJan Schneider <jan@horde.org>
Wed, 22 Sep 2010 15:01:39 +0000 (17:01 +0200)
framework/Core/lib/Horde.php
horde/docs/CODING_STANDARDS

index 901991d..d600537 100644 (file)
@@ -1667,6 +1667,9 @@ HTML;
      * Call a Horde hook, handling all of the necessary lookups and parsing
      * of the hook code.
      *
+     * WARNING: Throwing exceptions is expensive, so use callHook() with care
+     * and cache the results if you going to use the results more than once.
+     *
      * @param string $hook  The function to call.
      * @param array  $args  An array of any arguments to pass to the hook
      *                      function.
@@ -1681,7 +1684,8 @@ HTML;
         $error = false;
         $hook_class = $app . '_Hooks';
 
-        if (empty(self::$_hooksLoaded[$app]) && !class_exists($hook_class, false)) {
+        if (empty(self::$_hooksLoaded[$app]) &&
+            !class_exists($hook_class, false)) {
             try {
                 self::loadConfiguration('hooks.php', null, $app);
             } catch (Horde_Exception $e) {}
index 40733e1..80126dd 100644 (file)
@@ -617,6 +617,10 @@ to a Horde_Exception before throwing.
 When throwing a Horde_Exception the error message provided should not be
 localized.
 
+Throwing exceptions is expensive, so use them carefully for logic flow. You
+should cache results of Horde::callHook() calls for example, if you expect them
+to not exist.
+
 
 Existence checking
 ==================