mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
perf: avoid making copies of strings (#412)
This commit is contained in:
@ -60,10 +60,11 @@ impl CustomerInterface for Store {
|
|||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
.into_report()?;
|
.into_report()?;
|
||||||
maybe_customer.map_or(Ok(None), |customer| {
|
maybe_customer.map_or(Ok(None), |customer| {
|
||||||
if customer.name == Some(REDACTED.to_string()) {
|
// in the future, once #![feature(is_some_and)] is stable, we can make this more concise:
|
||||||
Err(errors::StorageError::CustomerRedacted)?
|
// `if customer.name.is_some_and(|ref name| name == REDACTED) ...`
|
||||||
} else {
|
match customer.name {
|
||||||
Ok(Some(customer))
|
Some(ref name) if name == REDACTED => Err(errors::StorageError::CustomerRedacted)?,
|
||||||
|
_ => Ok(Some(customer)),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -97,10 +98,9 @@ impl CustomerInterface for Store {
|
|||||||
.await
|
.await
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
.into_report()?;
|
.into_report()?;
|
||||||
if customer.name == Some(REDACTED.to_string()) {
|
match customer.name {
|
||||||
Err(errors::StorageError::CustomerRedacted)?
|
Some(ref name) if name == REDACTED => Err(errors::StorageError::CustomerRedacted)?,
|
||||||
} else {
|
_ => Ok(customer),
|
||||||
Ok(customer)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user