use assignment instead of define for fast classes
This commit is contained in:
parent
f8915333b0
commit
1c2bafe0e1
@ -188,6 +188,19 @@ Class.prototype.pushMethod = function (node) {
|
||||
}
|
||||
|
||||
if (kind === "") {
|
||||
if (this.isFast) {
|
||||
// use assignments instead of define properties for fast classes
|
||||
|
||||
var className = this.className;
|
||||
if (!node.static) className = t.memberExpression(className, t.identifier("prototype"));
|
||||
methodName = t.memberExpression(className, methodName, node.computed);
|
||||
|
||||
var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
|
||||
t.inheritsComments(expr, node);
|
||||
this.body.push(expr);
|
||||
return;
|
||||
}
|
||||
|
||||
kind = "value";
|
||||
}
|
||||
|
||||
|
||||
@ -37,31 +37,21 @@ var Test = (function (Foo) {
|
||||
|
||||
_inherits(Test, Foo);
|
||||
|
||||
_prototypeProperties(Test, {
|
||||
foo: {
|
||||
value: function () {
|
||||
var _Foo$foo, _Foo$foo2;
|
||||
Foo.foo.call(this);
|
||||
(_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
|
||||
},
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
}, {
|
||||
test: {
|
||||
value: function () {
|
||||
var _Foo$prototype$test3, _Foo$prototype$test4;
|
||||
Foo.prototype.test.call(this);
|
||||
(_Foo$prototype$test3 = Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$prototype$test4 = Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
|
||||
},
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
Test.prototype.test = function () {
|
||||
var _Foo$prototype$test3, _Foo$prototype$test4;
|
||||
Foo.prototype.test.call(this);
|
||||
(_Foo$prototype$test3 = Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$prototype$test4 = Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
Test.foo = function () {
|
||||
var _Foo$foo, _Foo$foo2;
|
||||
Foo.foo.call(this);
|
||||
(_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
|
||||
(_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
_prototypeProperties(Test, {}, {});
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
|
||||
@ -28,16 +28,11 @@ var Test = (function (Foo) {
|
||||
|
||||
_inherits(Test, Foo);
|
||||
|
||||
_prototypeProperties(Test, {
|
||||
test: {
|
||||
value: function () {
|
||||
return Foo.wow.call(this);
|
||||
},
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
Test.test = function () {
|
||||
return Foo.wow.call(this);
|
||||
};
|
||||
|
||||
_prototypeProperties(Test, {});
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user