-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Remove some old stuff that is not needed anymore #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -211,14 +210,14 @@ RedisClient.prototype.do_auth = function () { | |||
self.send_anyway = true; | |||
self.send_command("auth", [this.auth_pass], function (err, res) { | |||
if (err) { | |||
if (err.toString().match("LOADING")) { | |||
if (/LOADING/.test(err.toString())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
performance nit: creating these regular expressions as vars and moving them out of the send_command code-path would be a slight improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
however "auth" is pretty rare so... 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two thoughts here: can we not use err.message
rather than err.toString()
?
also, wouldn't all of these be better off using indexOf? err.message.indexOf('string') !== -1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great points @simontabor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simontabor err.message is very likely better but as far as I know a precompiled regex with .test is faster than .indexOf and it's at least more readable in my opinion. It's difficult to write a proper test to compare the regex against the .indexOf as v8 is very likely inlining everything right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't worry too much about perf here because it's in the auth
stanza, which is only used by a subset of Redis users, and even then is only called once per client connection, but not only that it's in the error pathway of the auth stanza, so this is a super rare code path.
I shouldn't have brought perf up ealier 😁
Mostly just need to worry about correctness
Some notes above, this one seems to be a fairly significant PR |
Feedback incorporated |
LGTM, thanks for helping to clean up this library! |
Remove some old stuff that is not needed anymore and fix js parser sending non-Errors as errors.
No description provided.