Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make memo a queue #70

Open
parzhitsky opened this issue May 31, 2020 · 0 comments
Open

Make memo a queue #70

parzhitsky opened this issue May 31, 2020 · 0 comments
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

Comments

@parzhitsky
Copy link
Member

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.

@parzhitsky parzhitsky transferred this issue from parzh/xrange Jun 1, 2020
@parzhitsky parzhitsky transferred this issue from parzh/xrange__func Jun 1, 2020
@parzhitsky parzhitsky added 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 labels Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant