Does PHP parse through code with comments or line breaks faster?

What makes php parse faster:

  • //
  • //
  • //
  • //
  • //

or

In other words, is this the extreme speed that is required to parse // comment compared to the time it takes to go through an empty line?

+4
source share
2 answers

Comments will be parsed into individual nodes in the parsing tree, but adjacent spaces of newline lines will result in only one node in the parsing tree.

Thus, the technical answer is a gap that will be analyzed faster, but it is marginal and completely negligible for any PHP script. Use the op cache, which will cause comments and spaces if compile time really matters to you.

+1
source

// are three or four more characters. //\n\r or //\n depending on the OS. But the new line is only two or one character \n\r or \n .

Modern translators are smart enough to optimize them. Instead, you should focus more on code readability.

+1
source

Source: https://habr.com/ru/post/1436735/


All Articles