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

Added suggested performance optimization #94

Merged
merged 2 commits into from
Nov 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ module.exports = {
*/
function read_constant_declaration() {
var result = this.node('classconstant'), name = null, value = null;
if (this.is('IDENTIFIER') || this.expect(this.tok.T_STRING)) {
if (this.token === this.tok.T_STRING || this.is('IDENTIFIER')) {
name = this.text();
this.next();
}
Expand Down
17 changes: 7 additions & 10 deletions src/parser/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,20 @@ module.exports = {
result = node(result, offset);
break;
case this.tok.T_DOUBLE_COLON:
var node = this.node('staticlookup'), offset;
this.next();

if(this.is('IDENTIFIER') || this.token === this.tok.T_STRING
|| this.token === this.tok.T_CLASS
) {
offset = this.node('constref');
if((this.next().token === this.tok.T_STRING || this.is('IDENTIFIER'))) {
var node = this.node('staticlookup');
var offset = this.node('constref');
var name = this.text();

this.next();
offset = offset(name);

if(this.token === this.tok.T_OBJECT_OPERATOR || this.token === this.tok.T_DOUBLE_COLON) {
this.error();
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible infinite loop and node may missing in graceful mode

result = node(result, offset);
}
}

result = node(result, offset);
break;
case this.tok.T_OBJECT_OPERATOR:
var node = this.node('propertylookup');
Expand Down