Skip to content

Fix path search - #46081

Merged
bors merged 2 commits into
rust-lang:masterfrom
GuillaumeGomez:fix-path-search
Nov 25, 2017
Merged

Fix path search#46081
bors merged 2 commits into
rust-lang:masterfrom
GuillaumeGomez:fix-path-search

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

@GuillaumeGomez
GuillaumeGomezforce-pushed the fix-path-search branch 3 times, most recently from 7d0d016 to 8da48f2CompareNovember 18, 2017 16:34
@shepmastershepmaster added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 18, 2017
@QuietMisdreavus

Copy link
Copy Markdown
Contributor

This changes the behavior when searching for paths, but it doesn't quite fix the issue?

Your PR

image

Current nightly

image

Current stable

image

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

Oh damn. Didn't take into account cases where the path doesn't start by the given search... I'll update it.

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

Ok fixed! The changed line is this one.

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

After thinking about it once again (and a few tests), I found my solution not good enough so I strongly improved the checkPath function. Works way better now.

Comment threadsrc/librustdoc/html/static/main.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Slice returns a new array, so this is a no-op. Did you want to .splice() instead? From the removed code side, it looks like the answer is yes.

More idiomatically, you can also push those that raen't the empty string.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

> x = [1,2,3];
(3) [1, 2, 3]
> x.splice(0, 1)
[1]
> x
(2) [2, 3]

So no, it clearly removes an entry from the array.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Oh damn, you're absolutely right. Didn't see the missing 'p'!

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

Fixed.

@HavvyHavvy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just checking for basic JS stuff, and no other basic JS mistakes found.

return MAX_LEV_DISTANCE + 1;
}
for (var i = 0; i < path.length; ++i) {
if (i + startsWith.length > path.length) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can use the condition used in the if statement as the for loop condition (when inverted), can't you?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Absolutely. I just have a personal preference to keep loop conditions as simple as possible. If someone else thinks it's a good idea, then I'll just update it.

}
lev_total += lev;
}
if (aborted === false) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Isn't it more common to check it like this: !aborted

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

It's slower. '!' tests (from memory): length !== 0, 0, null, undefined. So clearly, it's way better in js to make the comparison like this.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Didn't know that. Thanks for explaining it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Except you can generally rely on the JIT to figure out that aborted can only contain a boolean.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I did too much rust, I love being explicit. 😛

@QuietMisdreavus

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Nov 25, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit c00eaa9 has been approved by QuietMisdreavus

@bors

bors commented Nov 25, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit c00eaa9 with merge ca8ef26...

bors added a commit that referenced this pull request Nov 25, 2017
@bors

bors commented Nov 25, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: QuietMisdreavus
Pushing ca8ef26 to master...

@bors
bors merged commit c00eaa9 into rust-lang:masterNov 25, 2017
@borsbors mentioned this pull request Nov 25, 2017
@GuillaumeGomez
GuillaumeGomez deleted the fix-path-search branch November 25, 2017 15:28
@kennytmkennytm added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 27, 2017
@durkadurka mentioned this pull request Dec 20, 2017
bors added a commit that referenced this pull request Dec 23, 2017
[beta] Doc search backports
This is a backport of #46081, #46175, #46433, and #46672. They all merged cleanly but I haven't tried a build; let's see what Travis says.
These PRs fix pretty annoying issues with doc search and so I think it's important they don't slip to stable, but these PRs have *NOT* been `beta-accepted` yet.
cc @steveklabnik@GuillaumeGomez can you tag the docs team to talk about beta-acceptance?
@alexcrichton

Copy link
Copy Markdown
Member

Looks like we forgot to backport this to 1.23.0 (sorry about that!) so removing beta tags

@alexcrichtonalexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 10, 2018
@alexcrichton

Copy link
Copy Markdown
Member

Er sorry, looks like this was backported in #46886

@alexcrichtonalexcrichton added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jan 10, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-acceptedAccepted for backporting to the compiler in the beta channel.S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@GuillaumeGomez@QuietMisdreavus@bors@alexcrichton@Havvy@mzimnn@kennytm@shepmaster