Skip to content

Commit

Permalink
Improve performance while autoloading
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Sep 1, 2012
1 parent 6dd72cb commit ff81f79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ $/path/to/phpize
$./configure --with-php-config=/path/to/php-config/
$make && make install
```

### For windows
Yaf binary dlls could be found at http://code.google.com/p/yafphp/downloads/list

Expand Down
3 changes: 2 additions & 1 deletion php_yaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: php_yaf.h 327064 2012-08-12 03:04:55Z laruence $ */
/* $Id: php_yaf.h 327414 2012-09-01 12:44:40Z laruence $ */

#ifndef PHP_YAF_H
#define PHP_YAF_H
Expand Down Expand Up @@ -90,6 +90,7 @@ ZEND_BEGIN_MODULE_GLOBALS(yaf)
char *default_action;
char *bootstrap;
char *name_separator;
long name_separator_len;
zend_bool lowcase_path;
zend_bool use_spl_autoload;
zend_bool throw_exception;
Expand Down
13 changes: 11 additions & 2 deletions yaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf.c 327285 2012-08-26 09:12:27Z laruence $ */
/* $Id: yaf.c 327414 2012-09-01 12:44:40Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down Expand Up @@ -54,6 +54,15 @@ zend_function_entry yaf_functions[] = {
};
/* }}} */

/* {{{ PHP_INI_MH(OnUpdateSeparator)
*/
PHP_INI_MH(OnUpdateSeparator) {
YAF_G(name_separator) = new_value;
YAF_G(name_separator_len) = new_value_length;
return SUCCESS;
}
/* }}} */

/** {{{ PHP_INI
*/
PHP_INI_BEGIN()
Expand All @@ -63,7 +72,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("yaf.use_spl_autoload", "0", PHP_INI_ALL, OnUpdateBool, use_spl_autoload, zend_yaf_globals, yaf_globals)
STD_PHP_INI_ENTRY("yaf.forward_limit", "5", PHP_INI_ALL, OnUpdateLongGEZero, forward_limit, zend_yaf_globals, yaf_globals)
STD_PHP_INI_BOOLEAN("yaf.name_suffix", "1", PHP_INI_ALL, OnUpdateBool, name_suffix, zend_yaf_globals, yaf_globals)
STD_PHP_INI_ENTRY("yaf.name_separator", "", PHP_INI_ALL, OnUpdateString, name_separator, zend_yaf_globals, yaf_globals)
PHP_INI_ENTRY("yaf.name_separator", "", PHP_INI_ALL, OnUpdateSeparator)
STD_PHP_INI_BOOLEAN("yaf.cache_config", "0", PHP_INI_SYSTEM, OnUpdateBool, cache_config, zend_yaf_globals, yaf_globals)
/* {{{ This only effects internally */
STD_PHP_INI_BOOLEAN("yaf.st_compatible", "0", PHP_INI_ALL, OnUpdateBool, st_compatible, zend_yaf_globals, yaf_globals)
Expand Down
6 changes: 3 additions & 3 deletions yaf_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_loader.c 327269 2012-08-25 15:09:00Z laruence $ */
/* $Id: yaf_loader.c 327414 2012-09-01 12:44:40Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down Expand Up @@ -166,7 +166,7 @@ int yaf_loader_register(yaf_loader_t *loader TSRMLS_DC) {
/** {{{ static int yaf_loader_is_category(char *class, uint class_len, char *category, uint category_len TSRMLS_DC)
*/
static int yaf_loader_is_category(char *class, uint class_len, char *category, uint category_len TSRMLS_DC) {
uint separator_len = strlen(YAF_G(name_separator));
uint separator_len = YAF_G(name_separator_len);

if (YAF_G(name_suffix)) {
if (class_len > category_len && strncmp(class + class_len - category_len, category, category_len) == 0) {
Expand Down Expand Up @@ -760,7 +760,7 @@ PHP_METHOD(yaf_loader, autoload) {
return;
}

separator_len = strlen(YAF_G(name_separator));
separator_len = YAF_G(name_separator_len);
app_directory = YAF_G(directory);
origin_classname = class_name;

Expand Down

0 comments on commit ff81f79

Please sign in to comment.