laravel-pug icon indicating copy to clipboard operation
laravel-pug copied to clipboard

Refactor array_map and array_filter

Open HPWebdeveloper opened this issue 1 year ago • 1 comments

This Pull Request introduces a refactoring of the getPugEngine method within the ServiceProvider. The primary objectives are to simplify the logic for enhanced readability and to improve overall performance.

HPWebdeveloper avatar Dec 17 '23 13:12 HPWebdeveloper

array_map and array_filter was slow in the past (when they were actually PHP-coded functions), but have been rewritten in C and since they are actually faster than loops (and creating intermediate variables) in many situations (https://medium.com/@visheshahuja/php-array-map-vs-foreach-loop-18488c95aa18)

So unless some benchmark using recent PHP version, I wouldn't bet performance is a win here.

Also codes before and after here are not equivalent, it might break some untested cases, the readability improvement does not sound worthy to me as a first sight.

kylekatarnls avatar Dec 17 '23 15:12 kylekatarnls