Skip to content

Commit b4b0fa4

Browse files
committed
feat: faster log loading
1 parent 9f954cc commit b4b0fa4

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/app.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,14 @@ impl App {
219219
fn string_for_paragraph(s: &str, lines: usize, cols: usize, offset: usize) -> String {
220220
s.lines()
221221
.rev()
222+
.flat_map(|l| l.split('\r').rev()) // bandaid for term escape codes
222223
.skip(offset)
223224
.take(lines)
224225
.map(|l| l.chars().take(cols).collect::<String>())
225-
.collect::<Vec<String>>()
226+
.collect::<Vec<_>>()
226227
.into_iter()
227228
.rev()
228-
.collect::<Vec<String>>()
229+
.collect::<Vec<_>>()
229230
.join("\n")
230231
}
231232

src/file_watcher.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ impl FileReader {
122122
fn update(&self) -> Result<(), crossbeam::channel::SendError<Option<String>>> {
123123
let s = self.file_path.as_ref().and_then(|file_path| {
124124
// TODO: partial read only
125-
fs::read_to_string(file_path)
126-
.ok()
127-
.map(|s| s.replace("\r", "\n")) // .replace doesn't really belong here, but it can be slow because log files can be huge => so better to do it here (off the UI thread) for now
125+
fs::read_to_string(file_path).ok()
128126
});
129127
self.content_sender.send(s)
130128
}

0 commit comments

Comments
 (0)