Skip to content

Commit

Permalink
return early if the response is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Jan 21, 2012
1 parent f56784e commit 75c2834
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/memcached.js
Expand Up @@ -361,11 +361,15 @@ Client.config = {
}
};

function resultSetIsEmpty(resultSet) {
return !resultSet || (resultSet.length == 1 && !resultSet[0]);
}
// Parses down result sets
private.resultParsers = {
// combines the stats array, in to an object
'stats': function(resultSet){
var response = {};
if (resultSetIsEmpty(resultSet)) return response;

// add references to the retrieved server
response.server = this.serverAddress;
Expand All @@ -383,6 +387,7 @@ Client.config = {
// Group slabs by slab id
, 'stats slabs': function(resultSet){
var response = {};
if (resultSetIsEmpty(resultSet)) return response;

// add references to the retrieved server
response.server = this.serverAddress;
Expand All @@ -399,6 +404,7 @@ Client.config = {
}
, 'stats items': function(resultSet){
var response = {};
if (resultSetIsEmpty(resultSet)) return response;

// add references to the retrieved server
response.server = this.serverAddress;
Expand Down

0 comments on commit 75c2834

Please sign in to comment.