Skip to content

Commit 4b6ce89

Browse files
committed
Update expand implementation to slightly improve performance
1 parent 36ee62c commit 4b6ce89

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

internal/mithril-persistence/src/sqlite/condition.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,15 @@ impl WhereCondition {
7575
//
7676
// Replace parameters placeholders by numerated parameters.
7777
let mut final_expression = "".to_string();
78-
let mut value = "".to_string();
79-
let mut param_index = 0;
80-
for sql_part in expression.split("?*") {
81-
final_expression.push_str(&value);
78+
for (param_index, sql_part) in expression.split("?*").enumerate() {
79+
if param_index > 0 {
80+
final_expression.push('?');
81+
final_expression.push_str(&param_index.to_string());
82+
}
8283
final_expression.push_str(sql_part);
83-
param_index += 1;
84-
value = format!("?{}", param_index);
8584
}
8685

87-
(final_expression.to_string(), parameters)
86+
(final_expression, parameters)
8887
}
8988

9089
/// Instanciate a condition with a `IN` statement.

0 commit comments

Comments
 (0)