Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96241 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5313 invoked from network); 4 Oct 2016 19:31:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2016 19:31:18 -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.54 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:36000] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/1C-06241-48304F75 for ; Tue, 04 Oct 2016 15:31:17 -0400 Received: by mail-wm0-f54.google.com with SMTP id k125so225954485wma.1 for ; Tue, 04 Oct 2016 12:31:16 -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=vgqLEsmqA9ALOA+1MfmMy3GMXc4MmpTq4VG7Y+PTZMc=; b=BbfxcdxEix550EjcpcE/545NNNrR1qtOWU3h0i2XHtePaomCK/70oPEAnhi0ReCD+o h2m+E48x8FS9rOa0H+xMg8xexSNuzTIVpehPUbrMJ+2C3zZULTOPNuG4BXEDF3D3yk/d emx83Frqr+K6EQxjTPlLF9y/waKGBwxIsNp0F0MNsWE9LMQoRCZ1wTQ3XLialwQT2Xtz KkV2E8vJqMfQXhEe9UbD/8U4EdKu+56C/xmF3OZC0xSziThQhI1T4QYYXVKrKEb1oH/K PheMKCHEVxdtEIOJaujKAuW84O4UdhnZIjN1CTUZ9YM3MKqpcLaFemprd2EvPEl6cEHY gunw== 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=vgqLEsmqA9ALOA+1MfmMy3GMXc4MmpTq4VG7Y+PTZMc=; b=lFBInkFC9ENzvsPuReOsK6Qn4QdFW1rvBs7KrCaMOOw2QvW6cK6Q47Eodp5woozEyI WkI+efiD4ikWWXJ3zXIQBlj9EoebNPuYSkF0XYiTVd2Hn0w3GqTKaK5h5t+9iERHlSV1 0uo9mpgyQArVNo4TaL0ByvSQliSXl8ODMyKcr0x3TR7EhG/IgX34azezo/5nfD5FKd5K iXuOImhug/wGfCeE8u+ycUojZZeLEATrnzR/4wLHVy/xLUiyv/Lx4rsH5+JW3RzAaOLS IiMRCL1S81yAPLH3GBbSFcK2tyQvYEbHUsA+Q1Z7FS4pvFv31DuwQH4c6bBInT4CU0lP pK6g== X-Gm-Message-State: AA6/9Rm20FT/3/IQpBhx4z+IC6eK59x41NN159kWYENRpnnZM4THewaHDGnXTSAagE/yhdnp3zY8yL5zB2EIHg== X-Received: by 10.28.208.199 with SMTP id h190mr17771837wmg.17.1475609473000; Tue, 04 Oct 2016 12:31:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.197.73 with HTTP; Tue, 4 Oct 2016 12:31:12 -0700 (PDT) In-Reply-To: <000401d21e4c$3e71d140$bb5573c0$@lool.fr> References: <004101d21e33$124edf90$36ec9eb0$@lool.fr> <3bc3c57695cdf6207724db47e6dbbbab@koti.fimnet.fi> <000401d21e4c$3e71d140$bb5573c0$@lool.fr> Date: Tue, 4 Oct 2016 13:31:12 -0600 Message-ID: To: Pascal KISSIAN Cc: =?UTF-8?Q?Lauri_Kentt=C3=A4?= , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=94eb2c194348772908053e0f1a9f Subject: Re: [PHP-DEV] Feature Request: inline pseudo-instruction From: derokorian@gmail.com (Ryan Pallas) --94eb2c194348772908053e0f1a9f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 shoul= d > write a function, include it only once, and then simply call the function > instead of repeatedly >including the file. Calling a function is 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 i= s > 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 lead to a redesign of the functionality anyway. > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --94eb2c194348772908053e0f1a9f--