RE: [SMARTY-DEV] Trouble compiling tpl from resource plugin

From: Date: Tue, 16 Jul 2002 16:43:50 +0000
Subject: RE: [SMARTY-DEV] Trouble compiling tpl from resource plugin
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-194@lists.php.net to get a copy of this message
Well, I vote for urlencode. Basename only looks for slashes (\ and /) and double byte characters, according to the code. Gary >-----Original Message----- >From: Monte Ohrt [mailto:monte@ispi.net] >Sent: Tuesday, July 16, 2002 11:12 AM >To: gary@loescher.org >Cc: Jason Sweat; smarty-dev@lists.php.net >Subject: Re: [SMARTY-DEV] Trouble compiling tpl from >resource plugin > > >Using strpos, We are assuming that ":" is the only >character we're >looking for. Are there any other characters that >basename wouldn't >catch? In any event, urlencode is much faster and >covers everything. > >Gary Loescher wrote: >> Heh. I was just writing an email to suggest this >> same code. Great minds, Jason :) >> >> Looks like we're stuck with munged filenames >> again, or a performance hit. Personally, the >> filename doesn't bother me. I actually like >> being able to easily identify the resource >> used to get the template. In the "file:c:/foo.tpl" >> case, though, I guess that the price for >> using an absolute path would be funny-looking >> compiled template names. ;) Seems to me >> using an absolute path is a bad practice, anyway. >> >> Gary >> >> >>>-----Original Message----- >>>From: Jason Sweat [mailto:jsweat_php@yahoo.com] >>>Sent: Tuesday, July 16, 2002 10:36 AM >>>To: smarty-dev@lists.php.net; gary@loescher.org; >monte@ispi.net >>>Subject: Re: [SMARTY-DEV] Trouble compiling tpl from >>>resource plugin >>> >>> >>>What about this ? >>>if ($offset=strpos($string,':')) { >>> $offset++; >>>} >>>$match = substr($string,$offset); >>> >>> >>> >>>Well we may have to use urlencode instead of trying to >>>get the filename. >>>preg_match and preg_split are get what we want but are >>>much slower. >>> >>>repeated 100,000 times: >>> >>>urlencode(basename($string)); --> 2.920 >>>secs >>> >>>preg_match('![^:|/\\\\$]!',$string,$match); --> 7.627 >>>secs >>>explode(':',basename($string)); --> 5.436 secs >>> >>>The second two get it right, but they take much >>>longer. Unless there are >>>any other ideas? >>> >>>Monte >>> >>>__________________________________________________ >>>Do You Yahoo!? >>>Yahoo! Autos - Get free new car price quotes >>>http://autos.yahoo.com >>> >>>-- >>>Smarty Development Mailing List (http://smarty.php.net/) >>>To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> > > > >-- >Monte Ohrt <monte@ispi.net> >Director of Technology, ispi Inc. >

« previous php.smarty.dev (#194) next »