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

rustdoc-search: simplify checkPath and sortResults #118109

Merged
merged 2 commits into from
Nov 22, 2023

Commits on Nov 21, 2023

  1. rustdoc-search: clean up checkPath

    This computes the same result with less code by computing many of
    the old checks at once:
    
    * It won't enter the loop if clength > length, because then the
      result of length - clength will be negative and the
      loop conditional will fail.
    * i + clength will never be greater than length, because it
      starts out as i = length - clength, implying that i + clength
      equals length, and it only goes down from there.
    * The aborted variable is replaced with control flow.
    notriddle committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    d82a085 View commit details
    Browse the repository at this point in the history
  2. rustdoc-search: make primitives and keywords less special

    The search sorting code already sorts by item type discriminant,
    putting things with smaller discriminants first. There was
    also a special case for sorting keywords and primitives earlier,
    and this commit removes it by giving them lower discriminants.
    
    The sorting code has another criteria where items with descriptions
    appear earlier than items without, and that criteria has higher
    priority than the item type. This shouldn't matter, though,
    because primitives and keywords normally only appear in the
    standard library, and it always gives them descriptions.
    notriddle committed Nov 21, 2023
    Configuration menu
    Copy the full SHA
    28f17d9 View commit details
    Browse the repository at this point in the history