Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-24 Thread Yasuo Ohgaki
Hi Andrey, On Wed, Jun 24, 2015 at 6:20 PM, Andrey Andreev wrote: > On Wed, Jun 24, 2015 at 5:49 AM, Yasuo Ohgaki wrote: > > Hi Xinchen, > > > > On Wed, Jun 24, 2015 at 11:42 AM, Xinchen Hui wrote: > > > >> and for the "age" usage you replied in github, I think the author of > >> such codes sh

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-24 Thread Andrey Andreev
Hi, On Wed, Jun 24, 2015 at 5:49 AM, Yasuo Ohgaki wrote: > Hi Xinchen, > > On Wed, Jun 24, 2015 at 11:42 AM, Xinchen Hui wrote: > >> and for the "age" usage you replied in github, I think the author of >> such codes should be aware, if it's only number, then instead of >> htmlespcicalchars($age

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-24 Thread Xinchen Hui
Hey: On Wed, Jun 24, 2015 at 3:13 PM, Yasuo Ohgaki wrote: > Hi all, > > On Wed, Jun 24, 2015 at 12:20 PM, Yasuo Ohgaki wrote: >> >> On Wed, Jun 24, 2015 at 12:05 PM, Juan Basso wrote: >>> >>> Did you test the performance impact on strings? Since you changed how it >>> works the impact can be p

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-24 Thread Yasuo Ohgaki
Hi all, On Wed, Jun 24, 2015 at 12:20 PM, Yasuo Ohgaki wrote: > On Wed, Jun 24, 2015 at 12:05 PM, Juan Basso wrote: > >> Did you test the performance impact on strings? Since you changed how it >> works the impact can be positive and maybe worth to make the method more >> broad. > > > It's a bi

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Anthony, On Wed, Jun 24, 2015 at 12:00 PM, Yasuo Ohgaki wrote: > On Wed, Jun 24, 2015 at 10:40 AM, Anthony Ferrara > wrote: > >> > >> > IMHO, escape/unescape/encode/decode/conversion function is better to >> accept >> > any types. >> > HTML template may be separated script, but database code

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Juan, On Wed, Jun 24, 2015 at 12:05 PM, Juan Basso wrote: > Did you test the performance impact on strings? Since you changed how it > works the impact can be positive and maybe worth to make the method more > broad. It's a bit slower (~3%) for 'abc' as input string. If I remove redundant t

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Juan Basso
Yasuo, Did you test the performance impact on strings? Since you changed how it works the impact can be positive and maybe worth to make the method more broad. Juan Basso On Jun 23, 2015 23:01, "Yasuo Ohgaki" wrote: > Hi Anthony, > > On Wed, Jun 24, 2015 at 10:40 AM, Anthony Ferrara > wrote: >

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Anthony, On Wed, Jun 24, 2015 at 10:40 AM, Anthony Ferrara wrote: > > > > IMHO, escape/unescape/encode/decode/conversion function is better to > accept > > any types. > > HTML template may be separated script, but database code etc may not. > > > > Writing code like > > > > > declare(strict_

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Xinchen, On Wed, Jun 24, 2015 at 11:42 AM, Xinchen Hui wrote: > and for the "age" usage you replied in github, I think the author of > such codes should be aware, if it's only number, then instead of > htmlespcicalchars($age), he should use echo $age directly... which is > more faster. > T

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Xinchen Hui
Hey: On Wed, Jun 24, 2015 at 10:35 AM, Yasuo Ohgaki wrote: > Hi Xinchen, > > On Wed, Jun 24, 2015 at 11:31 AM, Xinchen Hui wrote: >> >> >> >> >> On Wed, Jun 24, 2015 at 8:32 AM, Yasuo Ohgaki wrote: >> > Hi Xinchen, >> > >> > On Tue, Jun 23, 2015 at 11:33 PM, Xinchen Hui wrote: >> >> >> >> But

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Xinchen, On Wed, Jun 24, 2015 at 11:31 AM, Xinchen Hui wrote: > > > > On Wed, Jun 24, 2015 at 8:32 AM, Yasuo Ohgaki wrote: > > Hi Xinchen, > > > > On Tue, Jun 23, 2015 at 11:33 PM, Xinchen Hui wrote: > >> > >> But passing an non-string to htmlspecialchars are not common used > cases.. > >>

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Xinchen Hui
Hey: On Wed, Jun 24, 2015 at 8:32 AM, Yasuo Ohgaki wrote: > Hi Xinchen, > > On Tue, Jun 23, 2015 at 11:33 PM, Xinchen Hui wrote: >> >> But passing an non-string to htmlspecialchars are not common used cases.. >> >> "optimize" not common used cases... will bring nothing to us.. > > > The reason

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Anthony Ferrara
Yasuo, > > IMHO, escape/unescape/encode/decode/conversion function is better to accept > any types. > HTML template may be separated script, but database code etc may not. > > Writing code like > > declare(strict_types=1); > $sql = 'SELECT * FROM '. pg_escape_identifier((string)$table). ' WHERE i

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Xinchen, On Tue, Jun 23, 2015 at 11:33 PM, Xinchen Hui wrote: > But passing an non-string to htmlspecialchars are not common used cases.. > > "optimize" not common used cases... will bring nothing to us.. > The reason why I looked into this in the first place is one of my friend complained a

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi all, On Wed, Jun 24, 2015 at 6:51 AM, Yasuo Ohgaki wrote: > I got it. > > On Wed, Jun 24, 2015 at 6:41 AM, Yasuo Ohgaki wrote: > >> On Wed, Jun 24, 2015 at 12:21 AM, Anthony Ferrara >> wrote: >> >>> In addition, this breaks the contract, specifically when using scalar >>> types. Because you

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Anthony, I got it. On Wed, Jun 24, 2015 at 6:41 AM, Yasuo Ohgaki wrote: > On Wed, Jun 24, 2015 at 12:21 AM, Anthony Ferrara > wrote: > >> In addition, this breaks the contract, specifically when using scalar >> types. Because you're no longer going to error when the contract is >> broken (c

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Stanislav Malyshev
Hi! > 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. I'm not sure this is the case that is used frequently enough to actually optimize for it in PHP code. If for part

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Anthony, On Wed, Jun 24, 2015 at 12:21 AM, Anthony Ferrara wrote: > In addition, this breaks the contract, specifically when using scalar > types. Because you're no longer going to error when the contract is > broken (considering htmlspecialchars is documented as string:string). > What do yo

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
Hi Xinchen, On Tue, Jun 23, 2015 at 11:33 PM, Xinchen Hui wrote: > But passing an non-string to htmlspecialchars are not common used cases.. > > "optimize" not common used cases... will bring nothing to us.. > The reason why I brought up this now is scalar type hint. Before PHP7, people didn't

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Anthony Ferrara
On Tue, Jun 23, 2015 at 10:33 AM, Xinchen Hui wrote: > Hey: > > On Tue, Jun 23, 2015 at 7:37 PM, Yasuo Ohgaki wrote: >> Hi all, >> >> I'm trying to optimize php_html_entities(). >> Since htmlspecialchars()/htmlentities() are sensitive function, I would >> like to ask comments before merge. >> >>

Re: [PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Xinchen Hui
Hey: On Tue, Jun 23, 2015 at 7:37 PM, Yasuo Ohgaki wrote: > 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_enti

[PHP-DEV] Optimizing php_html_entities()

2015-06-23 Thread Yasuo Ohgaki
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 n