Skip to content

Conversation

BridgeAR
Copy link
Contributor

@BridgeAR BridgeAR commented Sep 1, 2015

No description provided.

@@ -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())) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True :)

Copy link
Contributor

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... 😛

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great points @simontabor

Copy link
Contributor Author

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.

Copy link
Contributor

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

@brycebaril
Copy link
Contributor

Some notes above, this one seems to be a fairly significant PR

@BridgeAR
Copy link
Contributor Author

BridgeAR commented Sep 2, 2015

Feedback incorporated

@brycebaril
Copy link
Contributor

LGTM, thanks for helping to clean up this library!

BridgeAR added a commit that referenced this pull request Sep 2, 2015
Remove some old stuff that is not needed anymore and fix js parser sending non-Errors as errors.
@BridgeAR BridgeAR merged commit 38265d5 into redis:master Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants