Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7007 invoked from network); 4 Oct 2016 19:33:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2016 19:33:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:36841] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/7C-06241-BF304F75 for ; Tue, 04 Oct 2016 15:33:15 -0400 Received: by mail-wm0-f49.google.com with SMTP id k125so226052244wma.1 for ; Tue, 04 Oct 2016 12:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=DHTyjCNQij0yCqLHpgM2W8VpGPn1tOzGEwiKi7S5JZs=; b=VBKDqYh7XBN4Idu+6KyboxKgW9xhs6eOvS/8Jf90MwOw5ncxdMUtrZRwdgtAu/C4rw Tc1j0vPSb3urzKxImPMFfoacCoR+s5aau1qXkCyOdofUjdp7BAELxLGhfkK+UMOJ9JLj rWWTg0e9X9nGsiKoYf+Rp9K7elcIm5BX82i9DVh0k0o29XLmwKVUmfauRoLZnpcIsetu vFpQLOUJ/N9tHGWQmEGpM7Z40S9vNOQtWL6Cu8d/P5vkAkXFicSJWf/p3FBjAHzSLfWi eOg/8YGwjRJ4cujODzmm77bT5VZ9VVljDvT+3KY2Oum7gTYdmvZ9jk73d57VYvAxFKuS +V2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DHTyjCNQij0yCqLHpgM2W8VpGPn1tOzGEwiKi7S5JZs=; b=OBAOQXOdRqi3ml+2OlUXR/ziL55A3d2cJJyhNu6KWqndUzknEu419jmBw8fdI2/+Ju WKzNUnMZIh22se0AqkXosiSU7sFKMeUHdzAHdfKruPLCh3SAkUv8RFNnTS7ziLEwRmtb mG12V+/3vugzWubqINUWDrbu9FZX1qZ7XjHm/RSakkSew535y3vFegwEh7cPUvGJrgQx 28SOC5JElq/B2xW3Hz6vuSuwYvEY6sup3TjvEDdERqNhAC26MLbpldjIxU6B0MaeOSMA x8MPWs5avLS3tOsi6JM7wjOmXYYMqbf+lkbux1bLjGeMojkk0JEwb0SI1YqJm1xEwrh0 oKWA== X-Gm-Message-State: AA6/9RkG8w0vcDLnomJB9UcEeaXq/u7Eet1D13JyU5oUlaag5XeIhKGhma4vK8Qu61sTWde2ka3So4dqvmZQPQ== X-Received: by 10.194.188.113 with SMTP id fz17mr5444144wjc.179.1475609592809; Tue, 04 Oct 2016 12:33:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.197.73 with HTTP; Tue, 4 Oct 2016 12:33:12 -0700 (PDT) In-Reply-To: References: <004101d21e33$124edf90$36ec9eb0$@lool.fr> <3bc3c57695cdf6207724db47e6dbbbab@koti.fimnet.fi> <000401d21e4c$3e71d140$bb5573c0$@lool.fr> Date: Tue, 4 Oct 2016 13:33:12 -0600 Message-ID: To: Pascal KISSIAN Cc: =?UTF-8?Q?Lauri_Kentt=C3=A4?= , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7bb04fc29b4e72053e0f2189 Subject: Re: [PHP-DEV] Feature Request: inline pseudo-instruction From: derokorian@gmail.com (Ryan Pallas) --047d7bb04fc29b4e72053e0f2189 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Oct 4, 2016 at 1:31 PM, Ryan Pallas wrote: > > > On Tue, Oct 4, 2016 at 8:33 AM, Pascal KISSIAN > wrote: > >> >-----Message d'origine----- >> >De : Lauri Kentt=C3=A4 [mailto:lauri.kentta@gmail.com] >> >Envoy=C3=A9 : mardi 4 octobre 2016 16:21 >> >=C3=80 : Pascal KISSIAN >> >Cc : internals@lists.php.net >> >Objet : Re: [PHP-DEV] Feature Request: inline pseudo-instruction >> > >> >On 2016-10-04 14:33, Pascal KISSIAN wrote: >> >> I have an application where a small file is included at multiple >> >> places. >> >> >> >> The include is done about an average of 100.000 times . >> > >> >I'm just wondering if you have ever heard of functions? You really >> should write a function, include it only once, and then simply call the >> function instead of repeatedly >including the file. Calling a function i= s a >> lot faster than including a file. >> > >> >-- >> >Lauri Kentt=C3=A4 >> >> Function is not appropriate when the "inlined code" has to share 20-30 >> local variables ... >> Having a function with 30 args, or having to build and access an array >> is not very efficient nor natural... >> Local variables include 6 nested "for loop" indices and local >> variables/arrays needed for the computing. >> > > As many have said this may be a sign of a need to refactor. however, to > say that building an array and accessing it is not natural, consider that > you can use compact / extract. > > function doLoops($vars) { > extract($vars); > // many for loops > return compact(implode(' ', array_keys($vars))); > } > > // elsewhere set up a bunch of variables > extract(doLoops(compact('list of variable names goes here'))); > > Problem solved, now you are not including in a loop, but calling an > already compiled function, without adding TONS of lines of code to build > such an array. Its a short solution, to a problem that should probably le= ad > to a redesign of the functionality anyway. > > Sorry that should be compact(array_keys($vars)), and same for the list going in. Too many other languages lately! > >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > --047d7bb04fc29b4e72053e0f2189--