Bug #55591
closedDon't compute amount of seconds
0%
Description
There are many places in the core where the amount of secons is computed, e.g. 24 * 3600 * 7 (7 Days). Instead of computing this for every call, the evaluated number should directly be used.
Updated by Christian Kuhn almost 11 years ago
-1.
The calculation is done for readability (eg. in some ext_tables.php). Those are cached anyway ...
Furthermore: PHP compiler optimizes this away anyway, and a multiplication is so quick that we REALLY should not think about optimization for this detail in a high level language like PHP. Did you measure some benefit?
Updated by Mathias Brodala over 10 years ago
How about a date class which defines these values as constants? The Kohana framework does something like that:
https://github.com/kohana/core/blob/3.3/master/classes/Kohana/Date.php
Thus you can just use Date::WEEK
and be happy.
Updated by Mathias Schreiber almost 10 years ago
- Status changed from New to Closed
internally that is a static calculation and it will become a constant anyways ;-)