Tidy up DiversifierIndex::increment()

This commit is contained in:
Jack Grigg 2018-08-22 23:45:56 +01:00
parent ac8b27a5ba
commit e27fc674f5
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
1 changed files with 3 additions and 7 deletions

View File

@ -286,19 +286,15 @@ impl DiversifierIndex {
} }
pub fn increment(&mut self) -> Result<(), ()> { pub fn increment(&mut self) -> Result<(), ()> {
let mut k = 0; for k in 0..11 {
loop {
self.0[k] = self.0[k].wrapping_add(1); self.0[k] = self.0[k].wrapping_add(1);
if self.0[k] != 0 { if self.0[k] != 0 {
// No overflow // No overflow
return Ok(()); return Ok(());
} }
}
// Overflow // Overflow
k += 1; Err(())
if k == 11 {
return Err(());
}
}
} }
} }