mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +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
|
//TODO don't pass invisible lines
|
||||||
queue_editor_text(
|
queue_editor_text(
|
||||||
&size,
|
&size,
|
||||||
&ed_model.text_buf.all_lines(),
|
&ed_model.text_buf.all_lines(&arena),
|
||||||
ed_model.caret_pos,
|
ed_model.caret_pos,
|
||||||
CODE_TXT_XY.into(),
|
CODE_TXT_XY.into(),
|
||||||
&mut glyph_brush,
|
&mut glyph_brush,
|
||||||
|
|
|
@ -5,6 +5,8 @@ use crate::error::EdResult;
|
||||||
use crate::error::OutOfBounds;
|
use crate::error::OutOfBounds;
|
||||||
use crate::mvc::ed_model::{Position, RawSelection};
|
use crate::mvc::ed_model::{Position, RawSelection};
|
||||||
use crate::selection::validate_selection;
|
use crate::selection::validate_selection;
|
||||||
|
use bumpalo::collections::String as BumpString;
|
||||||
|
use bumpalo::Bump;
|
||||||
use ropey::Rope;
|
use ropey::Rope;
|
||||||
use snafu::{ensure, OptionExt};
|
use snafu::{ensure, OptionExt};
|
||||||
use std::fs::File;
|
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
|
// expensive function, don't use it if it can be done with a specialized, more efficient function
|
||||||
// TODO use bump allocation here
|
// TODO use bump allocation here
|
||||||
pub fn all_lines(&self) -> String {
|
pub fn all_lines<'a>(&self, arena: &'a Bump) -> BumpString<'a> {
|
||||||
let mut lines = String::new();
|
let mut lines = BumpString::with_capacity_in(self.text_rope.len_chars(), arena);
|
||||||
|
|
||||||
for line in self.text_rope.lines() {
|
for line in self.text_rope.lines() {
|
||||||
lines.extend(line.as_str());
|
lines.extend(line.as_str());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue