Possibly a stupid idea, but since all Zend classes are required to follow a specific standard instead of doing

require_once 'Zend/Exception.php';

Wouldn't

if(!class_exists('Zend_Exception')) {
        require 'Zend/Exception.php';
}

Work and be a lot faster, considering the number of files loaded for a simple application ( 32 ) it might make sense.


Richard Thomas - Code Monkey
Cyberlot Technologies Group Inc.
507.398.4124 - Voice


Matthew Weier O'Phinney wrote:
Due to the clamor on the list for lazy-loading of exceptions JIT, and
based in part on suggestions in that thread, I've added
Zend::exception() to the Zend class in both the incubator and core in
subversion.

As mentioned on the list, it does not actually throw the exception. The
reason for this is so that the throw happens at the location in the code
where it's necessary, not in a method in an unrelated class. This has
the benefit of putting the location of the throw as the first element
in the trace, making debugging more straightforward.

Additionally, if you need to manipulate the exception before throwing
it, returning the exception instead of throwing it makes this possible.

Usage is as follows:
// Assuming require_once 'Zend.php'; has been called previously
    throw Zend::exception('Zend_Acl_Exception', 'Incorrect permissions');

You can also optionally pass an exception code. The method uses
Zend::loadClass() to load the exception class, so the class name needs
to follow ZF naming conventions.

Another change made in the Zend class was to isReadable(). The algorithm
being used previously was a tad bit heavy performance-wise; the change I
made gives a 10-fold increase in performance, while retaining backwards
compatability.

Enjoy!

Reply via email to