Use (int) instead of intval() for performance reasons and to unify it. #4570
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Micro-optimization (no its not nano^^) of int/float casting.
(int) is about 3 times faster than the method call. Same for (float).
And we already mainly use (int), (float) casts etc where applicable.
I used my auto-correct Cast sniff
That means, we could make this a CakePHP code-sniffer rule to keep the improvement in the future.
It should be noted that I skipped on non-trivial replacements (more than a single argument) for now due to probably errors then (
intval($x + $y)
would need to keep the parentheses). It would be easy to keep the additional (superfluous) parentheses, if no-one minds though. That would probably eliminate the change of errors.// Inspired by this and this.