mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
arena heads-up comment, mem_arena -> arena, used seperate arena for GUI rects
This commit is contained in:
parent
581ef916fc
commit
cd8adb1d6d
5 changed files with 14 additions and 9 deletions
|
@ -32,7 +32,7 @@ fn text_buffer_from_str(lines_str: &str) -> TextBuffer {
|
|||
TextBuffer {
|
||||
text_rope: Rope::from_str(lines_str),
|
||||
path_str: "".to_owned(),
|
||||
mem_arena: Bump::new(),
|
||||
arena: Bump::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ fn text_buffer_from_str(lines_str: &str) -> TextBuffer {
|
|||
TextBuffer {
|
||||
text_rope: Rope::from_str(lines_str),
|
||||
path_str: "".to_owned(),
|
||||
mem_arena: bumpalo::Bump::new(),
|
||||
arena: bumpalo::Bump::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,11 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
|||
|
||||
let mut keyboard_modifiers = ModifiersState::empty();
|
||||
|
||||
// This arena is never cleared and should only be used for allocations that occur rarely
|
||||
let arena = Bump::new();
|
||||
|
||||
let mut rects_arena = Bump::new();
|
||||
|
||||
// Render loop
|
||||
window.request_redraw();
|
||||
|
||||
|
@ -313,9 +316,11 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
|||
);
|
||||
}
|
||||
|
||||
rects_arena.reset();
|
||||
|
||||
match draw_all_rects(
|
||||
&app_model.ed_model_opt,
|
||||
&arena,
|
||||
&rects_arena,
|
||||
&mut encoder,
|
||||
&frame.view,
|
||||
&gpu_device,
|
||||
|
|
|
@ -216,7 +216,7 @@ pub mod test_selection {
|
|||
TextBuffer {
|
||||
text_rope: Rope::from_str(lines_str),
|
||||
path_str: "".to_owned(),
|
||||
mem_arena: bumpalo::Bump::new(),
|
||||
arena: bumpalo::Bump::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::path::Path;
|
|||
pub struct TextBuffer {
|
||||
pub text_rope: Rope,
|
||||
pub path_str: String,
|
||||
pub mem_arena: Bump,
|
||||
pub arena: Bump,
|
||||
}
|
||||
|
||||
impl TextBuffer {
|
||||
|
@ -65,7 +65,7 @@ impl TextBuffer {
|
|||
} else {
|
||||
// happens very rarely
|
||||
let line_str = rope_slice.chunks().collect::<String>();
|
||||
let arena_str_ref = self.mem_arena.alloc(line_str);
|
||||
let arena_str_ref = self.arena.alloc(line_str);
|
||||
Ok(arena_str_ref)
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ impl TextBuffer {
|
|||
} else {
|
||||
// happens very rarely
|
||||
let line_str = rope_slice.chunks().collect::<String>();
|
||||
let arena_str_ref = self.mem_arena.alloc(line_str);
|
||||
let arena_str_ref = self.arena.alloc(line_str);
|
||||
Some(arena_str_ref)
|
||||
}
|
||||
} else {
|
||||
|
@ -144,12 +144,12 @@ impl TextBuffer {
|
|||
pub fn from_path(path: &Path) -> EdResult<TextBuffer> {
|
||||
let text_rope = rope_from_path(path)?;
|
||||
let path_str = path_to_string(path);
|
||||
let mem_arena = Bump::new();
|
||||
let arena = Bump::new();
|
||||
|
||||
Ok(TextBuffer {
|
||||
text_rope,
|
||||
path_str,
|
||||
mem_arena,
|
||||
arena,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue