简体   繁体   English

列表或单行数组/参数:一个或另一个执行得更好吗?

[英]List or single line array/parameters: Does one or the other perform better?

A little bit of a generic question but it has been playing on my mind for a while. 有点一般性的问题,但是我已经想了好一阵子了。

Whilst learning php coding, to help me create a WordPress Theme from scratch, I have noticed that some arrays/parameters are kept to a single line whilst others are listed underneath one an other. 在学习php编码的同时,为了帮助我从头开始创建WordPress主题,我注意到一些数组/参数被保留在一行中,而其他数组/参数则在另一行下面列出。 Personally, I prefer listing the arrays underneath one and other as I feel this helps with readability and generally just looks tidier - Especially, if the array is long. 就我个人而言,我更喜欢将数组列在一个数组之下,因为我认为这有助于提高可读性,并且通常看起来更整洁-特别是如果数组很长。

Does anyone know if listing arrays/parameters have any performance 'ill effects' such as slowing down the page load speed etc? 有谁知道列表数组/参数是否会对性能产生“不良影响”,例如降低页面加载速度等? As far as I can see, it is just a coder's preference. 据我所知,这只是编码人员的偏好。 Is this a correct assumption? 这是正确的假设吗?

Code formatting has no effect on performance. 代码格式化对性能没有影响。

Even if you claim that a larger file takes longer to read, if you are using at least PHP 5.5 then PHP will use an opcode cache - it will cache how it parsed your files for subsequent requests, eliminating any formatting that you have in your file. 即使您声称较大的文件需要更长的时间才能读取,但如果您至少使用PHP 5.5,则PHP将使用操作码缓存-它将缓存如何解析文件以用于后续请求,从而消除了文件中的任何格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM