Author: Derick Rethans
Date: 2007-05-03 15:37:13 +0200 (Thu, 03 May 2007)
New Revision: 5023
Log:
- Implemented issue #9988: Implement component preloading for better opcode
cache performance.
Modified:
trunk/Base/ChangeLog
trunk/Base/src/base.php
Modified: trunk/Base/ChangeLog
===================================================================
--- trunk/Base/ChangeLog 2007-05-03 13:34:37 UTC (rev 5022)
+++ trunk/Base/ChangeLog 2007-05-03 13:37:13 UTC (rev 5023)
@@ -6,6 +6,8 @@
- Fixed issue #10666: ezc_bootstrap.php fails on Windows.
- Implemented issue #9569: Add "autoload.php" as 3rd fallback autoload file to
search for.
+- Implemented issue #9988: Implement component preloading for better opcode
+ cache performance.
- Added exception class ezcBaseExtensionNotFoundException to be thrown when an
extension is required but is not found.
- Changed the ezcBaseInit::fetchConfig() method to return the value that was
Modified: trunk/Base/src/base.php
===================================================================
--- trunk/Base/src/base.php 2007-05-03 13:34:37 UTC (rev 5022)
+++ trunk/Base/src/base.php 2007-05-03 13:37:13 UTC (rev 5023)
@@ -42,6 +42,11 @@
protected static $packageDir;
/**
+ * @var string Contains whether component preloading should be used, or
not.
+ */
+ public static $preload = false;
+
+ /**
* @var array(string=>array) Stores info with additional paths where
* autoload files and classes for autoloading
* could be found. Each item of $repositoryDirs
@@ -74,7 +79,6 @@
* This class caches the requested class names (including the ones who
* failed to load).
*
- *
* @param string $className The name of the class that should be loaded.
*
* @return bool
@@ -207,6 +211,7 @@
*
* @param string $fileName Name of the autoload file.
* @param string $className Name of the class that should be autoloaded.
+ * @param string $prefix The prefix of the class repository.
*
* @return bool True is returned when the file is correctly loaded.
* Otherwise false is returned.
@@ -226,7 +231,20 @@
{
// Add the array to the cache, and include the requested file.
ezcBase::$autoloadArray = array_merge(
ezcBase::$autoloadArray, $array );
- ezcBase::loadFile( ezcBase::$autoloadArray[$className] );
+ if ( ezcBase::$preload && !preg_match( '/Exception$/',
$className ) )
+ {
+ foreach ( $array as $loadClassName => $file )
+ {
+ if ( $loadClassName !== 'ezcBase' && !class_exists(
$loadClassName, false ) && !interface_exists( $loadClassName, false ) &&
!preg_match( '/Exception$/', $loadClassName ) /*&& !class_exists(
$loadClassName, false ) && !interface_exists( $loadClassName, false )*/ )
+ {
+ ezcBase::loadFile(
ezcBase::$autoloadArray[$loadClassName] );
+ }
+ }
+ }
+ else
+ {
+ ezcBase::loadFile( ezcBase::$autoloadArray[$className] );
+ }
return true;
}
}
@@ -515,5 +533,18 @@
ezcBase::$repositoryDirs[$prefix] = array( 'basePath' =>
$basePath, 'autoloadDirPath' => $autoloadDirPath );
}
}
+
+ /*
+ * Turns on component preloading.
+ *
+ * If component preloading is enabled then as soon as one of the classes
+ * of a component is request, all other classes in the component are
+ * loaded as well (except for Exception classes).
+ */
+ public static function setPreload()
+ {
+ self::$preload = true;
+ self::autoload( 'ezcBase' );
+ }
}
?>
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components