[php-src] PR #23726: ext/standard: Optimize & Refactor pathinfo()
| From: | LamentXU123 | Date: | Thu, 17 Sep 2026 15:13:12 +0000 |
| Subject: | [php-src] PR #23726: ext/standard: Optimize & Refactor pathinfo() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38532@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23726
Author: LamentXU123
I try to rewrite the whole function because I don't think it's very much well written. My
implementation includes:
- Reuse the basename string for
PATHINFO_BASENAME and extensionless
PATHINFO_FILENAME results.
- Share the last-dot lookup for extension and filename when returning PATHINFO_ALL.
This implementation is faster then the original one in various aspect.
pathinfo('/var/www/html/index.php', PATHINFO_BASENAME):46% lower runtime
pathinfo('/var/www/html/index.php', PATHINFO_EXTENSION):35% lower runtime
pathinfo('/var/www/html/index.php', PATHINFO_FILENAME):40% lower runtime
pathinfo('/var/www/html/README', PATHINFO_FILENAME):52% lower runtime
And no regressions iintended.
I am wondering why agents scanning this stuff can't find the idea to rewrite this function.
Perhaps I am making some mistakes.