Skip to content
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

perf(makeDateFromInput): no need to match regex if input is a Date #1708

Merged
merged 2 commits into from Jul 1, 2014

Conversation

ptbrowne
Copy link

The moment constructor when passed a Date should be the fastest. There is
no need to match the aspNetJsonRegex before testing if the input is a
Date.

The moment constructor when passed a Date should be the fastest. There is
no need to match the aspNetJsonRegex before testing if the `input` is a
Date.
return;
}

var matched = aspNetJsonRegex.exec(input);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why jshint doesn't scream about that, but each function should have only one var at the top. Just declare it at the top and define it here. matched can also be set inside the if statement (its only used inside).

@icambron
Copy link
Member

icambron commented Jul 1, 2014

Makes sense. Thanks!

icambron added a commit that referenced this pull request Jul 1, 2014
perf(makeDateFromInput): no need to match regex if input is a Date
@icambron icambron merged commit b36a84c into moment:develop Jul 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants