Skip to content

O(n) fallback::Span::start/end #492

@Axel-Reactor

Description

@Axel-Reactor

I use syn to parse Rust files outside of Rust macros and I noticed really slow performance in fallback::Span.

The problem seems like that there is a SOURCE_MAP thread local that only keeps growing. I never destroy the threads, it's a thread pool. Now I could try to create new threads every time I call into syn, but this seems silly.

Also, why is SourceMap::files a Vec? It seems like the spans in FileInfo can never overlap, so why not just use a BTreeMap sorted by span.start to look up the files? At least then it would be O(log n) for look ups even if it keeps growing.

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