Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86808 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21410 invoked from network); 23 Jun 2015 11:37:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jun 2015 11:37:47 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.175 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.175 mail-yk0-f175.google.com Received: from [209.85.160.175] ([209.85.160.175:32975] helo=mail-yk0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/70-18293-A0549855 for ; Tue, 23 Jun 2015 07:37:46 -0400 Received: by ykdt186 with SMTP id t186so3532264ykd.0 for ; Tue, 23 Jun 2015 04:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=Xj5gmnYqPH0Jdxv0cbUdaa2iJJaxG300jU8y7FjSeOo=; b=LcTyksGUww/tkAdKmLGL4ug5onMIWgysW66gKlPBobyJy0pkxbxvS9UUPDhnHHOIdZ j7M3QiohB+o91xWa/SC1a0EhtsMnyV95Mdag0cpCiYIsqFGJyJOamlbB9aE2ihnpnZxJ HXpkYWCjgD9iqG+cnFX6U1hhjfMMlXDFs5sveIQXGV3x+H9auZd277oXFsDKlZYSZVbP V5rBibD9A3IBm6uZpw7ohPQdPIfPd3wqI8d0DZK6aNo+KrWwcxWdYvN4d7ooOgi01xe7 FuN2fhaOXzcLJhsS9VjVAZMfyAldsFJNy92V9FlyWRHDhxRqEhTLDLv75UNPg1hGO5xl 7ffQ== X-Received: by 10.170.126.13 with SMTP id s13mr41621972ykb.50.1435059463628; Tue, 23 Jun 2015 04:37:43 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.129.48.129 with HTTP; Tue, 23 Jun 2015 04:37:04 -0700 (PDT) Date: Tue, 23 Jun 2015 20:37:04 +0900 X-Google-Sender-Auth: pNQpqd7ZMAypWeCAlZWN2MLjeFA Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113980408fadaa05192dd179 Subject: Optimizing php_html_entities() From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a113980408fadaa05192dd179 Content-Type: text/plain; charset=UTF-8 Hi all, I'm trying to optimize php_html_entities(). Since htmlspecialchars()/htmlentities() are sensitive function, I would like to ask comments before merge. https://github.com/php/php-src/pull/1356 Current php_html_entities() convert int/float/etc to string, then convert it. int/float/etc is not required to be escaped. Optimize it by simply converting them to string. Simple benchmark shows about 60% execution time reduction. [yohgaki@dev github-php-src]$ ./php-bin b.php Time: 10.484607934952 [yohgaki@dev github-php-src]$ ./php-bin b.php Time: 10.867615222931 [yohgaki@dev github-php-src]$ ./php.new b.php Time: 3.9379420280457 [yohgaki@dev github-php-src]$ ./php.new b.php Time: 4.0694711208344 [yohgaki@dev github-php-src]$ cat b.php