diff --git a/crates/ra_editor/Cargo.toml b/crates/ra_editor/Cargo.toml index 039688d7df9..7ed7526ec5b 100644 --- a/crates/ra_editor/Cargo.toml +++ b/crates/ra_editor/Cargo.toml @@ -23,6 +23,10 @@ rand = "*" rand_xorshift = "*" lazy_static = "*" +[lib] +# 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 +bench = false + [[bench]] name = "translate_offset_with_edit_benchmark" harness = 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 89ed998235a..0f550fd39a2 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! { } fn compare_translates(c: &mut Criterion) { - let f1 = Fun::new("translate_after_edit", |b, _| { - b.iter(|| { - let d = &*DATA; - line_index_utils::translate_after_edit(&d.text, d.offset, d.edits.clone()); - }) - }); - - let f2 = Fun::new("translate_offset_with_edit", |b, _| { - b.iter(|| { - let d = &*DATA; - line_index_utils::translate_offset_with_edit(&d.line_index, d.offset, &d.edits); - }) - }); - - let functions = vec![f1, f2]; + let functions = vec![ + Fun::new("translate_after_edit", |b, _| { + b.iter(|| { + let d = &*DATA; + line_index_utils::translate_after_edit(&d.text, d.offset, d.edits.clone()); + }) + }), + Fun::new("translate_offset_with_edit", |b, _| { + b.iter(|| { + let d = &*DATA; + line_index_utils::translate_offset_with_edit(&d.line_index, d.offset, &d.edits); + }) + }), + ]; c.bench_functions("translate", functions, ()); } diff --git a/crates/ra_editor/src/line_index_utils.rs b/crates/ra_editor/src/line_index_utils.rs index 913ca5b150f..632c962cc2a 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( Step::Newline(n) => { if offset < *n { return res.to_line_col(offset); - } else if offset == *n { - res.add_line(*n); - return res.to_line_col(offset); } else { res.add_line(*n); }