Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

字符串常量的属性value名字可以bail掉htmlspecialchars #60

Open
HerringtonDarkholme opened this issue May 31, 2016 · 3 comments

Comments

@HerringtonDarkholme
Copy link
Contributor

input @type="text" @name="hehe"

output

echo   '<input';                                                               // 1, 1 @ a.jedi
echo     ' type="';                                                            // 1, 7 @ a.jedi
echo     htmlspecialchars(('text'), 0x88);
echo     '"';
echo     ' name="';                                                            // 1, 20 @ a.jedi
echo     htmlspecialchars(('hehe'), 0x88);
echo     '"';
echo    '>';

让开发者去区分单双引号来性能优化简直蛋疼

@hax
Copy link
Contributor

hax commented May 31, 2016

不用人肉优化,未来编译器会优化掉。(另外需要实际profiling,其实如果PHP engine比较聪明的话它自己应该会优化掉。)

但这跟单引号双引号无关。你换单引号实际编译结果是一样的。

@hax hax added this to the 2.0 (plan) milestone May 31, 2016
@HerringtonDarkholme
Copy link
Contributor Author

input @text='test' @name='hehe'

output

echo   '<input';                                                               // 1, 1 @ a.jedi
echo     ' text="test"';                                                       // 1, 7 @ a.jedi
echo     ' name="hehe"';                                                       // 1, 20 @ a.jedi
echo    '>';

@hax
Copy link
Contributor

hax commented Jun 1, 2016

好吧,我忘记什么时候做了这种 mirco optimization 了。但你可以先别管。
本身这个优化没有价值单独实现。我需要实现的是更一般的优化,即遍历整个ast,把所有const部分都在编译时计算掉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants