Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

refactor(*): faster check for a string starting with a substring #14660

Closed
wants to merge 1 commit into from

Conversation

petebacondarwin
Copy link
Member

Thanks to @spamdaemon for the original PR (#3711) to make this improvement.

In naive tests on Chrome I got the following results:

             Matches   Misses
indexOf      33ms      1494ms
lastIndexOf  11ms      11ms

Thanks to @spamdaemon for the original PR to make this improvement.

In naive tests on Chrome I got the following results:

```
             Matches   Misses
indexOf      33ms      1494ms
lastIndexOf  11ms      11ms
```

Closes angular#3711
@petebacondarwin
Copy link
Member Author

This is mostly to trigger Travis

@petebacondarwin
Copy link
Member Author

Landed as a4e4fee

@@ -909,7 +912,7 @@ function $LocationProvider() {
// update $location when $browser url changes
$browser.onUrlChange(function(newUrl, newState) {

if (isUndefined(beginsWith(appBaseNoFile, newUrl))) {
if (isUndefined(stripBaseUrl(appBaseNoFile, newUrl))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better
if (!startsWith(...)) {

?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would be good. Easy PR for you @lgalfaso :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok cfc8b41

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants