note 83964 added to function.str-replace

From: Date: Fri, 20 Jun 2008 14:54:29 +0000
Subject: note 83964 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-140625@lists.php.net to get a copy of this message
In response to jaimthorn's comment on June 20th: Thanks for pointing out the slow spot, and it's definitely good to have both examples here. Let me elaborate on the "slowness" a bit. It's a given that any kind of meta-programming technique (evaluating some code within your code, like create_function() does) is always slower than traditional approach, especially in the language which wasn't built with "dynamism" in mind. Just like "foreach" is slower than "for" -- there's always a choice between maintainability (clarity and decoupling of code, declarative style) vs. performance optimization (expanding pieces of code into simpler, faster routines, general redesign, etc.). The latter one basically turns the code into a mess. The best thing to do is to find a common ground. There's an easy way to get balanced - avoid premature optimization. Write code for clarity and conciseness, and only optimize certain parts when they become bottlenecks. IE, if your application only uses interpolation to send out an occasional e-mail - you are unlikely to ever need to optimize interpolate function, and rather keep the code clearer. However, if your application goes through millions of records interpolating them, this difference will be crucial, and a simple code profiling session will point out the bottleneck for you. Best regards, Max. ---- Server IP: 209.41.74.194 Probable Submitter: 209.10.106.40 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/83964 Del: integrated -- https://master.php.net/note/delete/83964/integrated Del: useless -- https://master.php.net/note/delete/83964/useless Del: bad code -- https://master.php.net/note/delete/83964/bad+code Del: spam -- https://master.php.net/note/delete/83964/spam Del: non-english -- https://master.php.net/note/delete/83964/non-english Del: in docs -- https://master.php.net/note/delete/83964/in+docs Del: other reasons-- https://master.php.net/note/delete/83964 Reject -- https://master.php.net/note/reject/83964 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140625) next »