Skip to content

Make Word.MergeAll sub-quadratic #7872

Open

Description

@svick

The current implementation of Word.MergeAll uses Vec<T>.Remove() to remove symbols from the list:

// Filter out the removed symbols
for (int i = _symbols.Count - 1; i >= 0; i--)
{
if (_symbols[i].Len == 0)
{
_symbols.Remove(i);
}
}

Based on data I found, it seems it's common that around 75 % of symbols are removed here (though the data conflates multiple steps, so it could be not fully relevant). This makes the method quadratic, likely significantly affecting its performance.

We should consider improving that. (This won't make the method linear, since the use of PriorityQueue<T> leads to at least O(n log n).)

Activity

  1. added
    area-TokenizersText tokenisation and tokenizer APIs
    and removed
    needs-area-labelAn area label could not be assigned confidently
    untriagedNew issue has not been triaged
    on Nov 2, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions