Skip to content

Refactoring discussion #348

@chylex

Description

@chylex

Continued from #341.

I haven't added documentation for many things yet, planning to do that at some point. EditorOffsetCache is a character position cache, I consider it to be valid for only one frame but theoretically it could be used until the user scrolls, however that would add overhead of re-checking the view for probably very little benefit (the main use comes from site ordering and by the time you press the second key, usually you exclude enough occurrences and tags it doesn't matter that you rebuild the cache).

One idea I've meant to implement for a while is a trie-based index.

I wanted to use a PATRICIA trie for tag comparisons in Map<String, _>, because it turns out computing hashes (interning tags seems to have helped a bit) and comparing strings gets expensive when you do it so many times. I've written a PATRICIA trie in Rust and C#, was considering porting them to Kotlin but not feeling up to the task while there's still work to be done on the refactor. I'd be careful about any other kinds of tries - from my experiments with several types of hand-written trie structures in Rust, PATRICIA tries were the only ones to outperform hash maps (and translating to C# gave me huge gains over a classic trie too); there's also a lot of misinformation about how exactly PATRICIA should be implemented, so that's fun.

I haven't considered tries for indexing n-grams, I don't know how worth it it'd be - the ratio of editor modifications and scrolling vastly outnumbers the amount of times I navigate via AceJump. I think with extremely long documents where you won't be able to tag everything (my refactor removes the old limit but it still ends up hitting one), a possible idea would be to not limit the amount of tags, but to limit the amount of sites before they're assigned. Even if some sites get missed, I find it difficult to imagine using AceJump in a huge file and being mad about a few missed tags when they get increasingly sparse as you move away from the cursor anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions