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

fix: memory management #6

Merged
merged 4 commits into from
Sep 23, 2023
Merged

Conversation

greged93
Copy link
Contributor

Fixes couple of issues in the memory, typos and adds couple of tests for the Memory.

@greged93 greged93 requested review from ClementWalter and Eikix and removed request for ClementWalter September 23, 2023 08:26
class MemorySegmentManager {
segmentSizes: Record<number, number>;
export class MemorySegmentManager {
segmentSizes: Record<Uint, Uint>;
Copy link
Member

@Eikix Eikix Sep 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general:

If you have a static set of keys or you want a type that behaves like a regular object but with type safety, Record is a good choice.
If you want a dynamic collection of key-value pairs with more utility methods and insertion order, then Map is the way to go.
Lastly, considering the branding on Uint, if you were to use the Record, keep in mind that object keys in JavaScript are always strings, so there might be some nuances with key conversion if you try to use the branded number directly as a key.

@@ -41,7 +41,7 @@ export class Felt {
}

toNumber(): number {
let num = Number(this.inner);
const num = Number(this.inner);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch

@Eikix Eikix merged commit 957f35b into kkrt-labs:main Sep 23, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants