-
Notifications
You must be signed in to change notification settings - Fork 1
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 the stack overflow caused by a static array of String #46
Conversation
163d3c4
to
1b7a652
Compare
1b7a652
to
6f18e6e
Compare
mem: vec![0; 65536], | ||
cartridge: Vec::new(), | ||
bootrom: include_bytes!("../dmg0.bin"), | ||
code_listing: [ARRAY_REPEAT_VALUE; 0xffff + 1], | ||
code_listing: vec![ARRAY_REPEAT_VALUE; 0xffff + 1], |
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.
didn't know the vec!
macro also supported the [x; N]
syntax. Nice.
fpt/src/memory.rs
Outdated
@@ -242,7 +242,7 @@ impl Memory { | |||
&mut self.mem[range] | |||
} | |||
|
|||
pub fn code_listing(&self) -> &[Option<String>; 0xffff + 1] { | |||
pub fn code_listing(&self) -> &Vec<Option<String>> { |
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.
btw the return type can also be &[Option<String>]
because Vec<T>
implements the Deref
and DerefMut
traits with type Target = T
(which is String
in our case)
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.
👍
6f18e6e
to
5b785de
Compare
No description provided.