Re: Feature Request: inline pseudo-instruction
| From: | Michał Brzuchalski | Date: | Tue, 04 Oct 2016 15:52:10 +0000 |
| Subject: | Re: Feature Request: inline pseudo-instruction | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96230@lists.php.net to get a copy of this message | ||
2016-10-04 17:39 GMT+02:00 Bob Weinand <bobwei9@hotmail.com>:
>
> > Am 4.10.2016 um 16:33 schrieb Pascal KISSIAN <php-mailing-list@lool.fr>:
> >
> >> -----Message d'origine-----
> >> De : Lauri Kenttä [mailto:lauri.kentta@gmail.com]
> >> Envoyé : mardi 4 octobre 2016 16:21
> >> À : Pascal KISSIAN <php-mailing-list@lool.fr>
> >> 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 is a
> lot faster than including a file.
> >>
> >> --
> >> Lauri Kenttä
> >
> > 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.
>
6-level nested loop and 20-30 local variables in scope has enought
complexity to refactor. This stuff definitelly needs refactor.
I wouldn't allow any developer to commit such code, it woudn't pass code
review.
There was time I also have such code but it wasn't maintainable, once
written was never beeing understood by any other developer.
I think you should read about CleanCode ->
https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882
> Hey,
>
> why do you think are your includes so slow?
> Apart from the include itself (which in itself is fairly slow due to
> filesystem access; or in case with opcache, at the very least copying the
> op_array etc.), it does exactly this: building an array and importing it
> into the included files scope.
>
> Also, 20-30 local variables? That sounds a bit like your code has way too
> many responsibilities in one same place. Perhaps you should restructure
> your code instead, but the way you describe it, no.
>
> If your code is so "hot", that also even function calls would be quite
> significant then you should probably really inline your code there as a
> perf optimization. Anyway, code with that many variables almost always can
> meaningfully refactored.
>
> It is not the languages task to optimize insane code ...
>
> Bob
>
>
>
>
>
--
regards / pozdrawiam,
--
Michał Brzuchalski
brzuchalski.com