[piwi] r588 committed - improved classloading order to reduce class loading time

5 views
Skip to first unread message

pi...@googlecode.com

unread,
Nov 22, 2010, 7:53:33 AM11/22/10
to piwi...@googlegroups.com
Revision: 588
Author: grobmeier
Date: Mon Nov 22 04:50:00 2010
Log: improved classloading order to reduce class loading time
http://code.google.com/p/piwi/source/detail?r=588

Modified:
/framework/trunk/piwi/index.php
/framework/trunk/piwi/lib/piwi/SwiftWrapper.class.php

=======================================
--- /framework/trunk/piwi/index.php Sun Nov 21 05:19:17 2010
+++ /framework/trunk/piwi/index.php Mon Nov 22 04:50:00 2010
@@ -62,15 +62,11 @@
require_once ("lib/piwi/classloader/ClassLoader.class.php");
require_once ("lib/zetacomponents/Base/src/base.php");
require_once ('lib/swiftmailer/classes/Swift.php');
+require_once ("lib/piwi/SwiftWrapper.class.php");

spl_autoload_register( array( 'ezcBase', 'autoload' ) );
+spl_autoload_register( array( 'SwiftWrapper', 'autoload' ) );
spl_autoload_register( array( 'ClassLoader', 'autoload' ) );
-spl_autoload_register( array('SwiftWrapper', 'autoload') );
-
-// TODO: Review if needed
-//Create the message
-//$message = Swift_Message::newInstance();
-//$message->setSubject('My subject');

/* Enable logging */
$logger = Logger :: getLogger('index.php');
=======================================
--- /framework/trunk/piwi/lib/piwi/SwiftWrapper.class.php Fri Nov 19
05:32:23 2010
+++ /framework/trunk/piwi/lib/piwi/SwiftWrapper.class.php Mon Nov 22
04:50:00 2010
@@ -1,11 +1,14 @@
<?php
-
+/**
+ * Wraps the original Swift autoloader to prevent swift init when not
necessary.
+ * The code could have been written in to Swift itself, but
+ */
class SwiftWrapper {
private static $dependency = false;
public static function autoload($class) {
if(!self::$dependency) {
- require_once 'lib/swiftmailer/swift_init.php';
self::$dependency = true;
+ require_once ('lib/swiftmailer/swift_init.php');
}
Swift::autoload($class);
}

Reply all
Reply to author
Forward
0 new messages