Skip to content

Commit f2d16df

Browse files
committed
Merge pull request #1047 from dingpinglv/Iss2445_RewriteCtor
Fixed #2445 refactor code for rendering classes to optimize performance
2 parents 218b3b8 + e16afc6 commit f2d16df

File tree

17 files changed

+563
-776
lines changed

17 files changed

+563
-776
lines changed

cocos2d/CCScheduler.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ cc.ArrayContainsObject = function (arr, findObj) {
170170
/**
171171
* find object from array by target
172172
* @param {Array} arr source array
173-
* @param {cc.ListEntry|cc.HashUpdateEntry|cc.HashSelectorEntry} findInt find target
174-
* @return {cc.ListEntry|cc.HashUpdateEntry|cc.HashSelectorEntry}
173+
* @param {cc.ListEntry|cc.HashUpdateEntry} findInt find target
174+
* @return {cc.ListEntry|cc.HashUpdateEntry}
175175
*/
176176
cc.HASH_FIND_INT = function (arr, findInt) {
177177
if (arr == null) {
@@ -331,12 +331,13 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{
331331
this._elapsed = 0;
332332
this._timesExecuted = 0;
333333
} else {
334+
var locTarget = this._target, locSelector = this._selector;
334335
if (this._runForever && !this._useDelay) {
335336
//standard timer usage
336337
this._elapsed += dt;
337338

338339
if (this._elapsed >= this._interval) {
339-
if (this._target && this._selector)
340+
if (locTarget && locSelector)
340341
this._callSelector();
341342
this._elapsed = 0;
342343
}
@@ -345,7 +346,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{
345346
this._elapsed += dt;
346347
if (this._useDelay) {
347348
if (this._elapsed >= this._delay) {
348-
if (this._target && this._selector)
349+
if (locTarget && locSelector)
349350
this._callSelector();
350351

351352
this._elapsed = this._elapsed - this._delay;
@@ -354,7 +355,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{
354355
}
355356
} else {
356357
if (this._elapsed >= this._interval) {
357-
if (this._target && this._selector)
358+
if (locTarget && locSelector)
358359
this._callSelector();
359360

360361
this._elapsed = 0;
@@ -363,7 +364,7 @@ cc.Timer = cc.Class.extend(/** @lends cc.Timer# */{
363364
}
364365

365366
if (this._timesExecuted > this._repeat)
366-
cc.Director.getInstance().getScheduler().unscheduleCallbackForTarget(this._target, this._selector);
367+
cc.Director.getInstance().getScheduler().unscheduleCallbackForTarget(locTarget, locSelector);
367368
}
368369
}
369370
}
@@ -999,4 +1000,3 @@ cc.Scheduler = cc.Class.extend(/** @lends cc.Scheduler# */{
9991000
}
10001001
});
10011002

1002-

0 commit comments

Comments
 (0)