-
Notifications
You must be signed in to change notification settings - Fork 76
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
Refactor array and fix memleak issue #556
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
5e5f61f
to
618738b
Compare
618738b
to
a2ffcc3
Compare
} | ||
|
||
fn set_length[T](self : Array[T], new_len : Int) -> Unit { | ||
// assert new_len >= 0 && new_len <= self.buf.len |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note this may be used in hot paths, where you want to optimize it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a better name would be truncate_length
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean split this function into two specialized functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think current implementation has many optimization points. So shall we keep this PR only refactoring? And do optimization in later PRs?
a2ffcc3
to
793a627
Compare
This PR refactor "builtin/array.mbt" to "builtin/arraycore.mbt" and "builtin/array.mbt".
The file "builtin/arraycore.mbt" contains core primitives to implement an array. And "builtin/array.mbt" has zero knowledge about what's the underlying type of
Array
.This abstraction make it easier to introducing compiling array to js native array.
This PR also fix the memleak issue.