On Sun, Mar 09, 2008 at 12:36:09AM +0000, Hans wrote: > Saturday, March 8, 2008, 11:58:35 PM, Hans wrote: > > > A less aggressive and more precise replacement can be done instead > > with: > > > foreach($g as $k=>$v) > > $fmt = preg_replace("/$k/",$v $fmt); > > that does not do it. Perhaps this, which asks for a word boundary: > > foreach($g as $k => $v) > $fmt = preg_replace( "/\\$k\\b/", $v, $fmt);
PmWiki doesn't do this for performance reasons -- FmtPageName() is one of the most frequently called functions in the codebase, and it has to be as quick as possible. In this case, str_replace() is a _lot_ quicker than doing multiple preg_replace() calls. Yes, the fact that globals "leak" into FmtPageName is a bit of a pain, but I'd rather find ways to avoid the leaks than to significantly slow down one of the most fundamental (and often called) parts of the code. Pm _______________________________________________ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel