From c23e3e6beb273ae8c0f8e616edb7ed1acb0271c4 Mon Sep 17 00:00:00 2001 From: David Rowley Date: Wed, 13 Jul 2022 15:03:47 +1200 Subject: Use list_copy_head() instead of list_truncate(list_copy(...), ...) Truncating off the end of a freshly copied List is not a very efficient way of copying the first N elements of a List. In many of the cases that are updated here, the pattern was only being used to remove the final element of a List. That's about the best case for it, but there were many instances where the truncate trimming the List down much further. 4cc832f94 added list_copy_head(), so let's use it in cases where it's useful. Author: David Rowley Discussion: https://postgr.es/m/1986787.1657666922%40sss.pgh.pa.us --- src/backend/optimizer/path/indxpath.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/backend/optimizer/path/indxpath.c') diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 0ef70ad7f11..7d176e7b00a 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -3026,14 +3026,12 @@ expand_indexqual_rowcompare(PlannerInfo *root, rc->rctype = (RowCompareType) op_strategy; rc->opnos = new_ops; - rc->opfamilies = list_truncate(list_copy(clause->opfamilies), - matching_cols); - rc->inputcollids = list_truncate(list_copy(clause->inputcollids), - matching_cols); - rc->largs = list_truncate(copyObject(var_args), - matching_cols); - rc->rargs = list_truncate(copyObject(non_var_args), - matching_cols); + rc->opfamilies = list_copy_head(clause->opfamilies, + matching_cols); + rc->inputcollids = list_copy_head(clause->inputcollids, + matching_cols); + rc->largs = list_copy_head(var_args, matching_cols); + rc->rargs = list_copy_head(non_var_args, matching_cols); iclause->indexquals = list_make1(make_simple_restrictinfo(root, (Expr *) rc)); } -- cgit v1.2.3