Skip to content

Commit

Permalink
shift in the while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Bridgewater committed Sep 16, 2015
1 parent 55d0036 commit 30ec1cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"mocha": true,

// Relaxing options
"boss": true, // Accept things like `while (command = keys.shift()) { ... }`
"boss": true, // Accept statements like `while (key = keys.pop()) {}`

"overrides": {
"examples/*.js": {
Expand Down
16 changes: 7 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,14 @@ RedisClient.prototype.flush_and_error = function (message) {

error = new Error(message);

while (this.offline_queue.length > 0) {
command_obj = this.offline_queue.shift();
while (command_obj = this.offline_queue.shift()) {
if (typeof command_obj.callback === "function") {
command_obj.callback(error);
}
}
this.offline_queue = new Queue();

while (this.command_queue.length > 0) {
command_obj = this.command_queue.shift();
while (command_obj = this.command_queue.shift()) {
if (typeof command_obj.callback === "function") {
command_obj.callback(error);
}
Expand Down Expand Up @@ -393,8 +391,8 @@ RedisClient.prototype.ready_check = function () {
RedisClient.prototype.send_offline_queue = function () {
var command_obj, buffered_writes = 0;

while (this.offline_queue.length > 0) {
command_obj = this.offline_queue.shift();
// TODO: Implement queue.pop() as it should be faster than shift and evaluate petka antonovs queue
while (command_obj = this.offline_queue.shift()) {
debug("Sending offline command: " + command_obj.command);
buffered_writes += !this.send_command(command_obj.command, command_obj.args, command_obj.callback);
}
Expand Down Expand Up @@ -826,12 +824,12 @@ RedisClient.prototype.pub_sub_command = function (command_obj) {
RedisClient.prototype.end = function () {
this.stream._events = {};

//clear retry_timer
if(this.retry_timer){
// Clear retry_timer
if (this.retry_timer){
clearTimeout(this.retry_timer);
this.retry_timer = null;
}
this.stream.on("error", function(){});
this.stream.on("error", function noop(){});

this.connected = false;
this.ready = false;
Expand Down

0 comments on commit 30ec1cd

Please sign in to comment.