Skip to content

Commit 3658d4c

Browse files
committed
avoid clone
1 parent c82b7d8 commit 3658d4c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

datafusion/core/src/datasource/statistics.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,28 +258,28 @@ pub fn compute_all_files_statistics(
258258
collect_stats: bool,
259259
inexact_stats: bool,
260260
) -> Result<(Vec<FileGroup>, Statistics)> {
261-
let mut file_groups = file_groups;
261+
let mut file_groups_with_stats = Vec::with_capacity(file_groups.len());
262262

263263
// First compute statistics for each file group
264-
for file_group in file_groups.iter_mut() {
265-
*file_group = compute_file_group_statistics(
266-
file_group.clone(),
264+
for file_group in file_groups {
265+
file_groups_with_stats.push(compute_file_group_statistics(
266+
file_group,
267267
Arc::clone(&file_schema),
268268
collect_stats,
269-
)?;
269+
)?);
270270
}
271271

272272
// Then summary statistics across all file groups
273273
let mut statistics =
274-
compute_summary_statistics(&file_groups, &file_schema, |file_group| {
274+
compute_summary_statistics(&file_groups_with_stats, &file_schema, |file_group| {
275275
file_group.statistics()
276276
});
277277

278278
if inexact_stats {
279279
statistics = statistics.to_inexact()
280280
}
281281

282-
Ok((file_groups, statistics))
282+
Ok((file_groups_with_stats, statistics))
283283
}
284284

285285
pub(crate) fn add_row_stats(

0 commit comments

Comments
 (0)