[wp-trac] [WordPress Trac] #48083: Use `**` operator to replace`pow()` function calls

WordPress Trac noreply at wordpress.org
Fri Sep 20 03:52:52 UTC 2019


#48083: Use `**` operator to replace`pow()` function calls
-------------------------------------------+-----------------------------
 Reporter:  ayeshrajans                    |      Owner:  (none)
     Type:  enhancement                    |     Status:  new
 Priority:  normal                         |  Milestone:  Awaiting Review
Component:  General                        |    Version:  trunk
 Severity:  trivial                        |   Keywords:  has-patch
  Focuses:  performance, coding-standards  |
-------------------------------------------+-----------------------------
 Another ticket for a PHP 5.6+ enhancement. With PHP 5.6, we can use the
 `**` operator instead of `pow()` function. Doc page of `pow()` function
 also suggests to use the operator.

 Using the `**` operator is about 4 times faster too.

 1. `**` operator:
 https://www.php.net/manual/en/language.operators.arithmetic.php
 2. `pow()` function: https://www.php.net/manual/en/function.pow.php
 3. Simple benchmark: https://3v4l.org/LMRcp

 Attached patch below will fix the only 2 instances we have in WordPress
 code base.

 SimplePie and GetID3 libraries have this pattern more frequently. I see
 @jrf has created an issue in SimplePie about a new release, so I will open
 a PR there to see if we can get this in SimplePie upstream. GetID3 library
 requires PHP 5.3, so I don't think we can get this improvement to
 upstream.

 Thank you.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48083>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list