[Pkg-javascript-commits] [backbone] 45/173: Deopt Underscore methods that change on arguments

Jonas Smedegaard dr at jones.dk
Wed Aug 31 07:44:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository backbone.

commit 7ed8582d197f2e191dc44b3e5ceb4588627e71fb
Author: Justin Ridgewell <justin at ridgewell.name>
Date:   Wed Oct 7 11:15:50 2015 -0400

    Deopt Underscore methods that change on arguments
    
    All of our currently deoptimized Underscore methods (`pick`, `omit`,
    `invoke`, `without`, and `difference`) change behavior based on the
    number of arguments pass to the call. This both adds `reduce` (and
    friends).
    
    Supersedes (and incorporates) #3810.
---
 backbone.js | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/backbone.js b/backbone.js
index 99e5a15..6449e39 100644
--- a/backbone.js
+++ b/backbone.js
@@ -87,9 +87,6 @@
         return _[method](this[attribute], cb(iteratee, this), context);
       };
       case 4: return function(iteratee, defaultVal, context) {
-        if(arguments.length < 2) {
-          return _[method](this[attribute], cb(iteratee, this));
-        }
         return _[method](this[attribute], cb(iteratee, this), defaultVal, context);
       };
       default: return function() {
@@ -1169,8 +1166,8 @@
   // Underscore methods that we want to implement on the Collection.
   // 90% of the core usefulness of Backbone Collections is actually implemented
   // right here:
-  var collectionMethods = { forEach: 3, each: 3, map: 3, collect: 3, reduce: 4,
-      foldl: 4, inject: 4, reduceRight: 4, foldr: 4, find: 3, detect: 3, filter: 3,
+  var collectionMethods = { forEach: 3, each: 3, map: 3, collect: 3, reduce: 0,
+      foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3,
       select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3,
       contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3,
       head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list