aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_editor/Cargo.toml4
-rw-r--r--crates/ra_editor/benches/translate_offset_with_edit_benchmark.rs29
-rw-r--r--crates/ra_editor/src/line_index_utils.rs3
3 files changed, 18 insertions, 18 deletions
diff --git a/crates/ra_editor/Cargo.toml b/crates/ra_editor/Cargo.toml
index 039688d7d..7ed7526ec 100644
--- a/crates/ra_editor/Cargo.toml
+++ b/crates/ra_editor/Cargo.toml
@@ -23,6 +23,10 @@ rand = "*"
23rand_xorshift = "*" 23rand_xorshift = "*"
24lazy_static = "*" 24lazy_static = "*"
25 25
26[lib]
27# so that criterion arguments work, see: https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options
28bench = false
29
26[[bench]] 30[[bench]]
27name = "translate_offset_with_edit_benchmark" 31name = "translate_offset_with_edit_benchmark"
28harness = false \ No newline at end of file 32harness = false \ No newline at end of file
diff --git a/crates/ra_editor/benches/translate_offset_with_edit_benchmark.rs b/crates/ra_editor/benches/translate_offset_with_edit_benchmark.rs
index 89ed99823..0f550fd39 100644
--- a/crates/ra_editor/benches/translate_offset_with_edit_benchmark.rs
+++ b/crates/ra_editor/benches/translate_offset_with_edit_benchmark.rs
@@ -65,21 +65,20 @@ lazy_static! {
65} 65}
66 66
67fn compare_translates(c: &mut Criterion) { 67fn compare_translates(c: &mut Criterion) {
68 let f1 = Fun::new("translate_after_edit", |b, _| { 68 let functions = vec![
69 b.iter(|| { 69 Fun::new("translate_after_edit", |b, _| {
70 let d = &*DATA; 70 b.iter(|| {
71 line_index_utils::translate_after_edit(&d.text, d.offset, d.edits.clone()); 71 let d = &*DATA;
72 }) 72 line_index_utils::translate_after_edit(&d.text, d.offset, d.edits.clone());
73 }); 73 })
74 74 }),
75 let f2 = Fun::new("translate_offset_with_edit", |b, _| { 75 Fun::new("translate_offset_with_edit", |b, _| {
76 b.iter(|| { 76 b.iter(|| {
77 let d = &*DATA; 77 let d = &*DATA;
78 line_index_utils::translate_offset_with_edit(&d.line_index, d.offset, &d.edits); 78 line_index_utils::translate_offset_with_edit(&d.line_index, d.offset, &d.edits);
79 }) 79 })
80 }); 80 }),
81 81 ];
82 let functions = vec![f1, f2];
83 82
84 c.bench_functions("translate", functions, ()); 83 c.bench_functions("translate", functions, ());
85} 84}
diff --git a/crates/ra_editor/src/line_index_utils.rs b/crates/ra_editor/src/line_index_utils.rs
index 913ca5b15..632c962cc 100644
--- a/crates/ra_editor/src/line_index_utils.rs
+++ b/crates/ra_editor/src/line_index_utils.rs
@@ -270,9 +270,6 @@ pub fn translate_offset_with_edit(
270 Step::Newline(n) => { 270 Step::Newline(n) => {
271 if offset < *n { 271 if offset < *n {
272 return res.to_line_col(offset); 272 return res.to_line_col(offset);
273 } else if offset == *n {
274 res.add_line(*n);
275 return res.to_line_col(offset);
276 } else { 273 } else {
277 res.add_line(*n); 274 res.add_line(*n);
278 } 275 }