Hi again,So we've got a nifty little reduce function that makes fairly heavy
use of helper functions. My view looks kinda look this:

by_id : {
    map: function(doc) {
        emit(doc._id, {doc.type: doc});
    },
    reduce : function(keys, vals, rereduce){

        function helper1(args){...};
        function helper2(args){...};
        function helper3(args){...};

        var result = [];
        for each val in vals
            if ( helper1(vals) ) result = helper2(val, result);
            else result = helper3(val, results);

        return result;
    }


but it bothers me a little that those three functions are defined every time
that reduce is run. I haven't measured the overhead, but my general
experience with javascript is that function creation has measurable
overhead. could couchdb make the view object itself available when reduce is
run, so I can stick other functions on its slots? like:

    helper1 : function(args){...},
    helper2 : function(args){...},
    helper3 : function(args){...},

    reduce : function(keys, vals, rereduce){


        var result = [];
        for each val in vals
            if ( view.helper1(vals) ) result = view.helper2(val, result);
            else result = view.helper3(val, results);

        return result;

Am I the only person who's worried about this?

Thanks,
A

Reply via email to