Skip to content

Optimize interop with url crate #68

@tjtelan

Description

@tjtelan

From #66

[...]
Obviously, to use a GitUrl as a url::Url, the conversion to url::Url still has to happen twice (because GitUrl::parse() incurs the conversion via GitUrl::is_valid()), but that can be optimized in a separate change, e.g. via a new GitUrl::parse_to_url(), or by removing the conversion from GitUrl::is_valid() altogether, leaving it to the caller to attempt the conversion.

In this scenario, the user wants to use the Url struct after being parsed by GitUrl::parse(). And this results in being run twice through Url::parse(), which is not efficient, not desirable.

Why is this happening? While the url crate is optional, it currently part of the default-features. And during GitUrl::parse(), we call Url::parse() to catch and throw errors that we miss or report inaccurately.

Ideally, I would like to improve the parser so we can throw accurate errors when we get malformed urls, and then specialize the url feature towards using the url crate.

Objectives:

  • Remove url::Url::parse() step from GitUrl::is_valid()
  • Create an optimized call to parse input into Url (i.e., GitUrl::parse_to_url())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions