Re: Some more plane hacking...

From: Date: Thu, 16 Aug 2001 00:34:39 +0000
Subject: Re: Some more plane hacking...
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1523@lists.php.net to get a copy of this message
> Do you mean that you implemented part of Smarty class in C or that you > instantiate existing Smarty class in C? I implemented part of it in C. Only a small part. ie. this: (leaving out all the other crap around this, like MINIT, etc..) PHP_FUNCTION(smarty) { pval *ga, *tmp; if(ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } add_property_string(this_ptr, "template_dir", SMG(template_dir), 1); add_property_string(this_ptr, "compile_dir", SMG(compile_dir), 1); add_property_string(this_ptr, "config_dir", SMG(config_dir), 1); add_property_string(this_ptr, "left_delimiter", SMG(left_delim), 1); add_property_string(this_ptr, "right_delimiter", SMG(right_delim), 1); add_property_long(this_ptr, "cache_lifetime", SMG(cache_lifetime)); add_property_bool(this_ptr, "debugging", SMG(debugging)); add_property_string(this_ptr, "debug_tpl", SMG(debug_tpl), 1); add_property_string(this_ptr, "debugging_ctrl", SMG(debugging_ctrl), 1); add_property_bool(this_ptr, "compile_check", SMG(compile_check)); add_property_bool(this_ptr, "force_compile", SMG(force_compile)); add_property_bool(this_ptr, "caching", SMG(caching)); add_property_string(this_ptr, "cache_dir", SMG(cache_dir), 1); add_property_bool(this_ptr, "insert_tag_check", SMG(insert_tag_check)); add_property_string(this_ptr, "tpl_file_ext", SMG(tpl_file_ext), 1); add_property_bool(this_ptr, "security", SMG(security)); add_property_bool(this_ptr, "show_info_header", SMG(show_info_header)); add_property_bool(this_ptr, "show_info_include", SMG(show_info_include)); /* global_assign[HTTP_SERVER_VARS][0] = 'SCRIPT_NAME' */ MAKE_STD_ZVAL(tmp); array_init(tmp); add_index_string(tmp, 0, "SCRIPT_NAME", 1); MAKE_STD_ZVAL(ga); array_init(ga); add_assoc_zval(ga, "HTTP_SERVER_VARS", tmp); add_property_zval(this_ptr, "global_assign", ga); } So no methods or anything, just some of the properties. With the ability then to set any property in your php.ini file or httpd.conf. Would need to work out a useful syntax for things like $global_assign and the other complex types you have. In the above I just did a single static instance of a 2-dimensional $global_assign. > It really depends, I guess. One reason Smarty is so great :) is because > Monte and I could easily hack on the PHP implementation of it -- having it > in C would severely limit that ability to change around code and see the > effects. I can see the speed benefits though. But some of the core functionality could still be done in C and you can simply extend the C class from userspace. For example, leave all the compiling stuff in user-space since that only happens once in a while and not on every request during typical usage but take a very good look at any user-space code that is executed on every request. Such as the "$smarty = new Smarty;" call and the fetch() and _process_template() methods. I realize this makes it more cumbersome to develop Smarty, but it is starting to be used in some rather large and heavily trafficked situations and if we could provide a way to speed all Smarty sites up by 25-50% I think it would be a good thing. By the way, I am not in any way asking you to do this. I need Smarty to be fast for something I am working on, so I am more than willing to put a bit of time in on this. -Rasmus

« previous php.pear.dev (#1523) next »