Skip to content

macro_rules follow logic allocates uselessly in the happy path #61543

Description

@oli-obk

E.g. in

let tokens = vec!["`=>`", "`,`", "`=`", "`|`", "`if`", "`in`"];
a vec is created, only to be thrown away if the macro actually works out. I think we can just turn most places into an early return in the happy path and then only allocate in the error path.

Do not work on this issue before #61541 is merged.

Also,

fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> IsInFollow {
hasn't had its docs updated to reflect the source changes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.WG-compiler-performanceWorking group: Compiler Performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions