Skip to content

Commit 9dacc97

Browse files
authored
Merge pull request #1355 from mich2000/chore/cargo-fix
apply cargo clippy fix
2 parents 2259a0b + 92c8190 commit 9dacc97

File tree

2 files changed

+60
-62
lines changed

2 files changed

+60
-62
lines changed

src/metrics.rs

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -196,35 +196,35 @@ impl Metrics {
196196
pub fn format_profile(&self) -> String {
197197
let mut ret = String::new();
198198
ret.push_str(&format!(
199-
"sled profile:\n\
199+
"sled profile:\n\
200200
{0: >17} | {1: >10} | {2: >10} | {3: >10} | {4: >10} | {5: >10} | {6: >10} | {7: >10} | {8: >10} | {9: >10}\n",
201-
"op",
202-
"min (us)",
203-
"med (us)",
204-
"90 (us)",
205-
"99 (us)",
206-
"99.9 (us)",
207-
"99.99 (us)",
208-
"max (us)",
209-
"count",
210-
"sum (s)"
211-
));
201+
"op",
202+
"min (us)",
203+
"med (us)",
204+
"90 (us)",
205+
"99 (us)",
206+
"99.9 (us)",
207+
"99.99 (us)",
208+
"max (us)",
209+
"count",
210+
"sum (s)"
211+
));
212212
ret.push_str(&format!(
213-
"{}\n",
214-
std::iter::repeat("-").take(134).collect::<String>()
215-
));
213+
"{}\n",
214+
"-".repeat(134)
215+
));
216216

217217
let p =
218218
|mut tuples: Vec<(String, _, _, _, _, _, _, _, _, _)>| -> String {
219219
tuples.sort_by_key(|t| (t.9 * -1. * 1e3) as i64);
220220
let mut ret = String::new();
221221
for v in tuples {
222222
ret.push_str(&format!(
223-
"{0: >17} | {1: >10.1} | {2: >10.1} | {3: >10.1} \
223+
"{0: >17} | {1: >10.1} | {2: >10.1} | {3: >10.1} \
224224
| {4: >10.1} | {5: >10.1} | {6: >10.1} | {7: >10.1} \
225225
| {8: >10.1} | {9: >10.1}\n",
226-
v.0, v.1, v.2, v.3, v.4, v.5, v.6, v.7, v.8, v.9,
227-
));
226+
v.0, v.1, v.2, v.3, v.4, v.5, v.6, v.7, v.8, v.9,
227+
));
228228
}
229229
ret
230230
};
@@ -241,7 +241,7 @@ impl Metrics {
241241
histo.percentile(100.) / 1e3,
242242
histo.count(),
243243
histo.sum() as f64 / 1e9,
244-
)
244+
)
245245
};
246246

247247
let sz = |name: &str, histo: &Histogram| {
@@ -256,20 +256,20 @@ impl Metrics {
256256
histo.percentile(100.),
257257
histo.count(),
258258
histo.sum() as f64,
259-
)
259+
)
260260
};
261261

262262
ret.push_str("tree:\n");
263263

264264
ret.push_str(&p(vec![
265-
lat("traverse", &self.tree_traverse),
266-
lat("get", &self.tree_get),
267-
lat("set", &self.tree_set),
268-
lat("merge", &self.tree_merge),
269-
lat("del", &self.tree_del),
270-
lat("cas", &self.tree_cas),
271-
lat("scan", &self.tree_scan),
272-
lat("rev scan", &self.tree_reverse_scan),
265+
lat("traverse", &self.tree_traverse),
266+
lat("get", &self.tree_get),
267+
lat("set", &self.tree_set),
268+
lat("merge", &self.tree_merge),
269+
lat("del", &self.tree_del),
270+
lat("cas", &self.tree_cas),
271+
lat("scan", &self.tree_scan),
272+
lat("rev scan", &self.tree_reverse_scan),
273273
]));
274274
let total_loops = self.tree_loops.load(Acquire);
275275
let total_ops = self.tree_get.count()
@@ -281,34 +281,34 @@ impl Metrics {
281281
+ self.tree_reverse_scan.count();
282282
let loop_pct = total_loops * 100 / (total_ops + 1);
283283
ret.push_str(&format!(
284-
"tree contention loops: {} ({}% retry rate)\n",
285-
total_loops, loop_pct
286-
));
284+
"tree contention loops: {} ({}% retry rate)\n",
285+
total_loops, loop_pct
286+
));
287287
ret.push_str(&format!(
288-
"tree split success rates: child({}/{}) parent({}/{}) root({}/{})\n",
289-
self.tree_child_split_success.load(Acquire)
290-
.to_formatted_string(&Locale::en)
291-
,
292-
self.tree_child_split_attempt.load(Acquire)
293-
.to_formatted_string(&Locale::en)
294-
,
295-
self.tree_parent_split_success.load(Acquire)
296-
.to_formatted_string(&Locale::en)
297-
,
298-
self.tree_parent_split_attempt.load(Acquire)
299-
.to_formatted_string(&Locale::en)
300-
,
301-
self.tree_root_split_success.load(Acquire)
302-
.to_formatted_string(&Locale::en)
303-
,
304-
self.tree_root_split_attempt.load(Acquire)
305-
.to_formatted_string(&Locale::en)
306-
,
307-
));
288+
"tree split success rates: child({}/{}) parent({}/{}) root({}/{})\n",
289+
self.tree_child_split_success.load(Acquire)
290+
.to_formatted_string(&Locale::en)
291+
,
292+
self.tree_child_split_attempt.load(Acquire)
293+
.to_formatted_string(&Locale::en)
294+
,
295+
self.tree_parent_split_success.load(Acquire)
296+
.to_formatted_string(&Locale::en)
297+
,
298+
self.tree_parent_split_attempt.load(Acquire)
299+
.to_formatted_string(&Locale::en)
300+
,
301+
self.tree_root_split_success.load(Acquire)
302+
.to_formatted_string(&Locale::en)
303+
,
304+
self.tree_root_split_attempt.load(Acquire)
305+
.to_formatted_string(&Locale::en)
306+
,
307+
));
308308

309309
ret.push_str(&format!(
310-
"{}\n",
311-
std::iter::repeat("-").take(134).collect::<String>()
310+
"{}\n",
311+
"-".repeat(134)
312312
));
313313
ret.push_str("pagecache:\n");
314314
ret.push_str(&p(vec![
@@ -327,7 +327,7 @@ impl Metrics {
327327

328328
ret.push_str(&format!(
329329
"{}\n",
330-
std::iter::repeat("-").take(134).collect::<String>()
330+
"-".repeat(134)
331331
));
332332
ret.push_str("serialization and compression:\n");
333333
ret.push_str(&p(vec![
@@ -341,7 +341,7 @@ impl Metrics {
341341

342342
ret.push_str(&format!(
343343
"{}\n",
344-
std::iter::repeat("-").take(134).collect::<String>()
344+
"-".repeat(134)
345345
));
346346
ret.push_str("log:\n");
347347
ret.push_str(&p(vec![
@@ -403,7 +403,7 @@ impl Metrics {
403403

404404
ret.push_str(&format!(
405405
"{}\n",
406-
std::iter::repeat("-").take(134).collect::<String>()
406+
"-".repeat(134)
407407
));
408408
ret.push_str("segment accountant:\n");
409409
ret.push_str(&p(vec![
@@ -417,7 +417,7 @@ impl Metrics {
417417

418418
ret.push_str(&format!(
419419
"{}\n",
420-
std::iter::repeat("-").take(134).collect::<String>()
420+
"-".repeat(134)
421421
));
422422
ret.push_str("recovery:\n");
423423
ret.push_str(&p(vec![

src/serialization.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,10 @@ fn shift_i64_opt(value_opt: &Option<i64>) -> i64 {
433433

434434
const fn unshift_i64_opt(value: i64) -> Option<i64> {
435435
if value == 0 {
436-
None
437-
} else if value < 0 {
438-
Some(value)
439-
} else {
440-
Some(value - 1)
436+
return None
441437
}
438+
let subtract = value > 0;
439+
Some(value - subtract as i64)
442440
}
443441

444442
impl Serialize for Snapshot {

0 commit comments

Comments
 (0)