Skip to content

Commit f97118f

Browse files
committed
Added suggested performance optimization
1 parent c353382 commit f97118f

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/parser/class.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ module.exports = {
183183
*/
184184
function read_constant_declaration() {
185185
var result = this.node('classconstant'), name = null, value = null;
186-
if (this.is('IDENTIFIER') || this.expect(this.tok.T_STRING)) {
186+
if (this.token === this.tok.T_STRING || this.is('IDENTIFIER')) {
187187
name = this.text();
188188
this.next();
189189
}

src/parser/variable.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,20 @@ module.exports = {
127127
result = node(result, offset);
128128
break;
129129
case this.tok.T_DOUBLE_COLON:
130-
var node = this.node('staticlookup'), offset;
131-
this.next();
132-
133-
if(this.is('IDENTIFIER') || this.token === this.tok.T_STRING
134-
|| this.token === this.tok.T_CLASS
135-
) {
136-
offset = this.node('constref');
130+
if((this.next().token === this.tok.T_STRING || this.is('IDENTIFIER'))) {
131+
var node = this.node('staticlookup');
132+
var offset = this.node('constref');
137133
var name = this.text();
134+
138135
this.next();
139136
offset = offset(name);
140-
137+
141138
if(this.token === this.tok.T_OBJECT_OPERATOR || this.token === this.tok.T_DOUBLE_COLON) {
142139
this.error();
140+
} else {
141+
result = node(result, offset);
143142
}
144143
}
145-
146-
result = node(result, offset);
147144
break;
148145
case this.tok.T_OBJECT_OPERATOR:
149146
var node = this.node('propertylookup');

0 commit comments

Comments
 (0)