From 3fcd0c8b468db6f26ef174fca41f505a23ebcf1d Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Wed, 17 May 2017 17:46:51 +0800 Subject: [PATCH] no need to copy arguments for apply, see petkaantonov/bluebird#1389 --- cocos2d/core/components/CCLabel.js | 8 ++------ cocos2d/core/components/CCRichText.js | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index 0fb83f157c..89b2e75b4f 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -134,18 +134,14 @@ function debounce (func, wait, immediate) { if (callNow) func.apply(context, args); } : function () { var context = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } var later = function() { timeout = null; - if (!immediate) func.apply(context, args); + if (!immediate) func.apply(context, arguments); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); - if (callNow) func.apply(context, args); + if (callNow) func.apply(context, arguments); }; } diff --git a/cocos2d/core/components/CCRichText.js b/cocos2d/core/components/CCRichText.js index 4ef0be0231..55fa13a377 100644 --- a/cocos2d/core/components/CCRichText.js +++ b/cocos2d/core/components/CCRichText.js @@ -47,18 +47,14 @@ function debounce (func, wait, immediate) { if (callNow) func.apply(context, args); } : function () { var context = this; - var args = new Array(arguments.length); - for (var i = 0; i < arguments.length; i++) { - args[i] = arguments[i]; - } var later = function() { timeout = null; - if (!immediate) func.apply(context, args); + if (!immediate) func.apply(context, arguments); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); - if (callNow) func.apply(context, args); + if (callNow) func.apply(context, arguments); }; }