Skip to content

DocumentVersionCache should use circular (or ring) buffers #9811

@DustinCampbell

Description

@DustinCampbell

DocumentVersionCache caps the number of IDocumentSnapshot versions that are tracked for a particular document file path at 20. There are a couple of improvements that can be made to this part of the implementation:

  1. It holds the IDocumentSnapshot instances in weak references but never makes any attempt to clean out expired references. So, it will continue to store snapshots (up to 20), even if there are expired entries.
  2. The snapshots are stored in a List<T>. Once 20 snapshots have been cached, future snapshots result in RemoveAt(0) being called, which results in an array copy for every future snapshot. This could be alleviated by using a different structure, such as a circular buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions