diff options
author | Bernardo <[email protected]> | 2018-12-22 21:11:10 +0000 |
---|---|---|
committer | Bernardo <[email protected]> | 2018-12-25 19:03:14 +0000 |
commit | c886b72dab918d6f4d3be025135f769bc429cc79 (patch) | |
tree | f96737e3f2f4512aff9521743a124fe1c1326b8c /crates/ra_editor | |
parent | dc2afae991892719b97b0e4b40d8483b43b08680 (diff) |
make criterion args work, small simplification
Diffstat (limited to 'crates/ra_editor')
-rw-r--r-- | crates/ra_editor/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/ra_editor/benches/translate_offset_with_edit_benchmark.rs | 29 | ||||
-rw-r--r-- | crates/ra_editor/src/line_index_utils.rs | 3 |
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 = "*" | |||
23 | rand_xorshift = "*" | 23 | rand_xorshift = "*" |
24 | lazy_static = "*" | 24 | lazy_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 | ||
28 | bench = false | ||
29 | |||
26 | [[bench]] | 30 | [[bench]] |
27 | name = "translate_offset_with_edit_benchmark" | 31 | name = "translate_offset_with_edit_benchmark" |
28 | harness = false \ No newline at end of file | 32 | 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 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 | ||
67 | fn compare_translates(c: &mut Criterion) { | 67 | fn 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 | } |