Skip to content

Why isn't TBQueue backed by an array? #65

Closed

Description

@konsumlamm

I expected TBQueue to be backed by an array, instead of a pair of lists. This would get rid of the amortization and should cause less allocations. Have there been any benchmarks showing that the current version is faster?

Activity

  1. bgamari commented on Sep 6, 2023

    @bgamari
    Contributor

    I suppose you want something like the following?

    data TBQueue a
       = TBQueue
            (TArray a) -- a ring buffer of entries
            (TVar Int) -- Index of first queued entry
            (TVar Int)  -- Index of last queued entry

    This sounds plausible to me.

    The implementation is likely as it is since no one has tried improving it. Do try writing an array based implementation and benchmark it against the current list-based approach.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions