Make memo a queue #70
Labels
Change: patch
[Issue / PR] describes a small non-breaking change, such as bugfix or an optimization
Domain: main
[Issue / PR] describes change in the functionality, its optimization
good first issue
[Issue] can be addressed by a first-time contributor
Pending: unclear
[Issue] not yet fully defined
Priority: high
[Issue / PR] must be addressed as soon as possible
Type: improvement
[Issue / PR] addresses lack of a functionality or an open possibility of enhancement
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. Wouldmemo
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 bothPredicate
andNextFactory
);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.The text was updated successfully, but these errors were encountered: