mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
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
This commit is contained in:
@@ -2464,7 +2464,7 @@ truncate_useless_pathkeys(PlannerInfo *root,
|
||||
else if (nuseful == list_length(pathkeys))
|
||||
return pathkeys;
|
||||
else
|
||||
return list_truncate(list_copy(pathkeys), nuseful);
|
||||
return list_copy_head(pathkeys, nuseful);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user