mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-30 13:42:24 +03:00
perf: use .to_string() instead of single-param format!
Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
parent
529d87bc88
commit
69d35063f2
@ -34,8 +34,8 @@ impl<'ast> fmt::Display for RangeOrExpression<'ast> {
|
||||
RangeOrExpression::Range(ref range) => write!(
|
||||
f,
|
||||
"{}..{}",
|
||||
range.from.as_ref().map(|v| format!("{}", v)).unwrap_or(format!("")),
|
||||
range.to.as_ref().map(|v| format!("{}", v)).unwrap_or(format!("")),
|
||||
range.from.as_ref().map(|v| v.to_string()).unwrap_or("".to_string()),
|
||||
range.to.as_ref().map(|v| v.to_string()).unwrap_or("".to_string()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,7 @@ impl<'ast> fmt::Display for Variables<'ast> {
|
||||
write!(f, "{}", self.names[0])?;
|
||||
} else {
|
||||
// (a, mut b)
|
||||
let names = self
|
||||
.names
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
let names = self.names.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",");
|
||||
|
||||
write!(f, "({})", names)?;
|
||||
}
|
||||
|
@ -62,6 +62,6 @@ impl From<Error<Rule>> for ParserError {
|
||||
|
||||
impl From<std::io::Error> for ParserError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
ParserError::Crate("std::io", format!("{}", error))
|
||||
ParserError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ impl<'ast> fmt::Display for DefinitionStatement<'ast> {
|
||||
let expressions = self
|
||||
.expressions
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
|
||||
|
@ -36,6 +36,6 @@ pub enum OutputFileError {
|
||||
|
||||
impl From<std::io::Error> for OutputFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
OutputFileError::Crate("std::io", format!("{}", error))
|
||||
OutputFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
// Call a circuit function that can mutate self.
|
||||
|
||||
// Save a reference to the circuit we are mutating.
|
||||
let circuit_id_string = format!("{}", circuit_identifier);
|
||||
let circuit_id_string = circuit_identifier.to_string();
|
||||
let declared_circuit_reference = new_scope(function_scope.clone(), circuit_id_string);
|
||||
|
||||
(
|
||||
|
@ -268,7 +268,7 @@ impl EdwardsGroupType {
|
||||
if element.is_on_curve() {
|
||||
Ok(element)
|
||||
} else {
|
||||
Err(GroupError::not_on_curve(format!("{}", element), element_span))
|
||||
Err(GroupError::not_on_curve(element.to_string(), element_span))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> fmt::Display for ConstrainedValue<F
|
||||
write!(f, "]")
|
||||
}
|
||||
ConstrainedValue::Tuple(ref tuple) => {
|
||||
let values = tuple.iter().map(|x| format!("{}", x)).collect::<Vec<_>>().join(", ");
|
||||
let values = tuple.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "({})", values)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ fn test_undefined() {
|
||||
ExpressionError::Error(error),
|
||||
))) => {
|
||||
assert_eq!(
|
||||
format!("{}", error),
|
||||
error.to_string(),
|
||||
vec![
|
||||
" --> \"/test/src/main.leo\": 2:12",
|
||||
" |",
|
||||
|
@ -56,14 +56,14 @@ impl fmt::Display for Value {
|
||||
Value::I64(value) => value.value.map(|v| v.to_string()),
|
||||
Value::I128(value) => value.value.map(|v| v.to_string()),
|
||||
Value::Array(values) => {
|
||||
let string = values.iter().map(|v| format!("{}", v)).collect::<Vec<_>>().join(", ");
|
||||
let string = values.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "[{}]", string)?;
|
||||
|
||||
Some("".to_owned())
|
||||
}
|
||||
Value::Tuple(values) => {
|
||||
let string = values.iter().map(|v| format!("{}", v)).collect::<Vec<_>>().join(", ");
|
||||
let string = values.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "[{}]", string)?;
|
||||
|
||||
|
@ -50,7 +50,7 @@ impl<'ast> fmt::Display for Expression<'ast> {
|
||||
let values = array
|
||||
.expressions
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
|
||||
@ -60,7 +60,7 @@ impl<'ast> fmt::Display for Expression<'ast> {
|
||||
let values = tuple
|
||||
.expressions
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
|
||||
|
@ -29,12 +29,7 @@ pub struct TupleType<'ast> {
|
||||
|
||||
impl<'ast> std::fmt::Display for TupleType<'ast> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
let tuple = self
|
||||
.types_
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
let tuple = self.types_.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "({})", tuple)
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ impl_cli_error!(
|
||||
impl From<clap::Error> for CLIError {
|
||||
fn from(error: clap::Error) -> Self {
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("clap", format!("{}", error))
|
||||
CLIError::Crate("clap", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,34 +180,34 @@ impl From<leo_input::errors::InputParserError> for CLIError {
|
||||
impl From<reqwest::Error> for CLIError {
|
||||
fn from(error: reqwest::Error) -> Self {
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("rewquest", format!("{}", error))
|
||||
CLIError::Crate("rewquest", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<snarkos_errors::algorithms::snark::SNARKError> for CLIError {
|
||||
fn from(error: snarkos_errors::algorithms::snark::SNARKError) -> Self {
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("snarkos_errors", format!("{}", error))
|
||||
CLIError::Crate("snarkos_errors", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<snarkos_errors::gadgets::SynthesisError> for CLIError {
|
||||
fn from(error: snarkos_errors::gadgets::SynthesisError) -> Self {
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("snarkos_errors", format!("{}", error))
|
||||
CLIError::Crate("snarkos_errors", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::error::Error> for CLIError {
|
||||
fn from(error: serde_json::error::Error) -> Self {
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("serde_json", format!("{}", error))
|
||||
CLIError::Crate("serde_json", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for CLIError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
tracing::error!("{}\n", error);
|
||||
CLIError::Crate("std::io", format!("{}", error))
|
||||
CLIError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -75,9 +75,9 @@ impl Updater {
|
||||
} else {
|
||||
// If the auto update configuration is off, notify the user to update leo.
|
||||
if let Some(latest_version) = Self::update_available().unwrap() {
|
||||
let mut message = format!("{}", "🟢 A new version is available! Run".bold().green());
|
||||
message += &format!("{}", " `leo update` ".bold().white());
|
||||
message += &format!("{}", &(format!("to update to v{}.", latest_version)).bold().green());
|
||||
let mut message = "🟢 A new version is available! Run".bold().green().to_string();
|
||||
message += &" `leo update` ".bold().white();
|
||||
message += &format!("to update to v{}.", latest_version).bold().green();
|
||||
|
||||
tracing::info!("\n{}\n", message);
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ pub enum InputFileError {
|
||||
|
||||
impl From<std::io::Error> for InputFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
InputFileError::Crate("std::io", format!("{}", error))
|
||||
InputFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ pub enum StateFileError {
|
||||
|
||||
impl From<std::io::Error> for StateFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
StateFileError::Crate("std::io", format!("{}", error))
|
||||
StateFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ pub enum ChecksumFileError {
|
||||
|
||||
impl From<std::io::Error> for ChecksumFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
ChecksumFileError::Crate("std::io", format!("{}", error))
|
||||
ChecksumFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ pub enum CircuitFileError {
|
||||
|
||||
impl From<std::io::Error> for CircuitFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
CircuitFileError::Crate("std::io", format!("{}", error))
|
||||
CircuitFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ pub enum ProofFileError {
|
||||
|
||||
impl From<std::io::Error> for ProofFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
ProofFileError::Crate("std::io", format!("{}", error))
|
||||
ProofFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ pub enum ProvingKeyFileError {
|
||||
|
||||
impl From<std::io::Error> for ProvingKeyFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
ProvingKeyFileError::Crate("std::io", format!("{}", error))
|
||||
ProvingKeyFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,6 @@ pub enum VerificationKeyFileError {
|
||||
|
||||
impl From<std::io::Error> for VerificationKeyFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
VerificationKeyFileError::Crate("std::io", format!("{}", error))
|
||||
VerificationKeyFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -17,72 +17,72 @@ pub enum PackageError {
|
||||
|
||||
impl From<std::io::Error> for PackageError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
PackageError::Crate("std::io", format!("{}", error))
|
||||
PackageError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::GitignoreError> for PackageError {
|
||||
fn from(error: crate::errors::GitignoreError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::InputFileError> for PackageError {
|
||||
fn from(error: crate::errors::InputFileError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::InputsDirectoryError> for PackageError {
|
||||
fn from(error: crate::errors::InputsDirectoryError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::ImportsDirectoryError> for PackageError {
|
||||
fn from(error: crate::errors::ImportsDirectoryError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::OutputsDirectoryError> for PackageError {
|
||||
fn from(error: crate::errors::OutputsDirectoryError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::READMEError> for PackageError {
|
||||
fn from(error: crate::errors::READMEError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::SourceDirectoryError> for PackageError {
|
||||
fn from(error: crate::errors::SourceDirectoryError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::StateFileError> for PackageError {
|
||||
fn from(error: crate::errors::StateFileError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::LibraryFileError> for PackageError {
|
||||
fn from(error: crate::errors::LibraryFileError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::ManifestError> for PackageError {
|
||||
fn from(error: crate::errors::ManifestError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::errors::MainFileError> for PackageError {
|
||||
fn from(error: crate::errors::MainFileError) -> Self {
|
||||
PackageError::Crate("leo-package", format!("{}", error))
|
||||
PackageError::Crate("leo-package", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ pub enum GitignoreError {
|
||||
|
||||
impl From<std::io::Error> for GitignoreError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
GitignoreError::Crate("std::io", format!("{}", error))
|
||||
GitignoreError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ pub enum READMEError {
|
||||
|
||||
impl From<std::io::Error> for READMEError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
READMEError::Crate("std::io", format!("{}", error))
|
||||
READMEError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,6 @@ pub enum ZipFileError {
|
||||
|
||||
impl From<std::io::Error> for ZipFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
ZipFileError::Crate("std::io", format!("{}", error))
|
||||
ZipFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ pub enum LibraryFileError {
|
||||
|
||||
impl From<std::io::Error> for LibraryFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
LibraryFileError::Crate("std::io", format!("{}", error))
|
||||
LibraryFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ pub enum MainFileError {
|
||||
|
||||
impl From<std::io::Error> for MainFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
MainFileError::Crate("std::io", format!("{}", error))
|
||||
MainFileError::Crate("std::io", error.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ impl TryFrom<&TypedRecord> for DPCRecordValues {
|
||||
|
||||
// Lookup record owner
|
||||
let owner_value = find_input(OWNER_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
let owner = AccountAddress::<Components>::from_str(&format!("{}", owner_value))?;
|
||||
let owner = AccountAddress::<Components>::from_str(&owner_value.to_string())?;
|
||||
|
||||
// Lookup record is_dummy
|
||||
let is_dummy_value = find_input(IS_DUMMY_PARAMETER_STRING.to_owned(), ¶meters)?;
|
||||
|
@ -44,12 +44,7 @@ impl fmt::Display for Variables {
|
||||
write!(f, "{}", self.names[0])?;
|
||||
} else {
|
||||
// (a, mut b)
|
||||
let names = self
|
||||
.names
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
let names = self.names.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",");
|
||||
|
||||
write!(f, "({})", names)?;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ fn test_error() {
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
format!("{}", err),
|
||||
err.to_string(),
|
||||
vec![
|
||||
" --> file.leo: 2:8",
|
||||
" |",
|
||||
|
@ -242,7 +242,7 @@ impl<'ast> fmt::Display for Expression {
|
||||
|
||||
// Tuples
|
||||
Expression::Tuple(ref tuple, ref _span) => {
|
||||
let values = tuple.iter().map(|x| format!("{}", x)).collect::<Vec<_>>().join(", ");
|
||||
let values = tuple.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "({})", values)
|
||||
}
|
||||
|
@ -53,13 +53,8 @@ impl Function {
|
||||
|
||||
fn format(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "function {}", self.identifier)?;
|
||||
let parameters = self
|
||||
.input
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
let returns = self.returns.as_ref().map(|type_| format!("{}", type_));
|
||||
let parameters = self.input.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",");
|
||||
let returns = self.returns.as_ref().map(|type_| type_.to_string());
|
||||
let statements = self
|
||||
.statements
|
||||
.iter()
|
||||
|
@ -260,12 +260,12 @@ impl fmt::Display for InputValue {
|
||||
InputValue::Field(ref field) => write!(f, "{}", field),
|
||||
InputValue::Integer(ref type_, ref number) => write!(f, "{}{:?}", number, type_),
|
||||
InputValue::Array(ref array) => {
|
||||
let values = array.iter().map(|x| format!("{}", x)).collect::<Vec<_>>().join(", ");
|
||||
let values = array.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "array [{}]", values)
|
||||
}
|
||||
InputValue::Tuple(ref tuple) => {
|
||||
let values = tuple.iter().map(|x| format!("{}", x)).collect::<Vec<_>>().join(", ");
|
||||
let values = tuple.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "({})", values)
|
||||
}
|
||||
|
@ -189,11 +189,7 @@ impl fmt::Display for Statement {
|
||||
match *self {
|
||||
Statement::Return(ref expression, ref _span) => write!(f, "return {}", expression),
|
||||
Statement::Definition(ref declare, ref variable, ref expressions, ref _span) => {
|
||||
let formatted_expressions = expressions
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",");
|
||||
let formatted_expressions = expressions.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",");
|
||||
|
||||
write!(f, "{} {} = {};", declare, variable, formatted_expressions)
|
||||
}
|
||||
|
@ -217,15 +217,11 @@ impl fmt::Display for Type {
|
||||
Type::Circuit(ref variable) => write!(f, "circuit {}", variable),
|
||||
Type::SelfType => write!(f, "SelfType"),
|
||||
Type::Array(ref array, ref dimensions) => {
|
||||
let dimensions = dimensions
|
||||
.iter()
|
||||
.map(|x| format!("{}", x))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
let dimensions = dimensions.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
write!(f, "[{}; ({})]", *array, dimensions)
|
||||
}
|
||||
Type::Tuple(ref tuple) => {
|
||||
let types = tuple.iter().map(|x| format!("{}", x)).collect::<Vec<_>>().join(", ");
|
||||
let types = tuple.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(", ");
|
||||
|
||||
write!(f, "({})", types)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user