Skip to content

Make memo a queue #70

@parzhitsky

Description

@parzhitsky

memo is implemented as a simple JavaScript array (a stack). When being limited, it should have elements removed from its head, and this operation is O(n) in stacks, which is a pain in the arse. Would memo be implemented as a queue, this operation would be O(1), but the API might be changed in a way that's not intuitive for JavaScript developers.

Make sure that:

  • memo is a queue (in both Predicate and NextFactory);
  • all elements of memo are properly index-accessible, similar to arrays (Proxy?);
  • .unshift() is an alias for .enqueue(); .pop() is an alias for .dequeue();

It is worth noting for anybody who is reading this, that mutating memo is undefined behavior, and could lead to nasty hard-to-trace bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Change: patch[Issue / PR] describes a small non-breaking change, such as bugfix or an optimizationDomain: main[Issue / PR] describes change in the functionality, its optimizationPending: unclear[Issue] not yet fully definedPriority: high[Issue / PR] must be addressed as soon as possibleType: improvement[Issue / PR] addresses lack of a functionality or an open possibility of enhancementgood first issue[Issue] can be addressed by a first-time contributor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions