mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Used bump allocation for TextBuffer::all_lines
This commit is contained in:
parent
76e2edff97
commit
1f90c6f47b
2 changed files with 5 additions and 3 deletions
|
@ -257,7 +257,7 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
|||
//TODO don't pass invisible lines
|
||||
queue_editor_text(
|
||||
&size,
|
||||
&ed_model.text_buf.all_lines(),
|
||||
&ed_model.text_buf.all_lines(&arena),
|
||||
ed_model.caret_pos,
|
||||
CODE_TXT_XY.into(),
|
||||
&mut glyph_brush,
|
||||
|
|
|
@ -5,6 +5,8 @@ use crate::error::EdResult;
|
|||
use crate::error::OutOfBounds;
|
||||
use crate::mvc::ed_model::{Position, RawSelection};
|
||||
use crate::selection::validate_selection;
|
||||
use bumpalo::collections::String as BumpString;
|
||||
use bumpalo::Bump;
|
||||
use ropey::Rope;
|
||||
use snafu::{ensure, OptionExt};
|
||||
use std::fs::File;
|
||||
|
@ -90,8 +92,8 @@ impl TextBuffer {
|
|||
|
||||
// expensive function, don't use it if it can be done with a specialized, more efficient function
|
||||
// TODO use bump allocation here
|
||||
pub fn all_lines(&self) -> String {
|
||||
let mut lines = String::new();
|
||||
pub fn all_lines<'a>(&self, arena: &'a Bump) -> BumpString<'a> {
|
||||
let mut lines = BumpString::with_capacity_in(self.text_rope.len_chars(), arena);
|
||||
|
||||
for line in self.text_rope.lines() {
|
||||
lines.extend(line.as_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue