Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pass by reference in make_partfunc_call #4438

Merged
merged 1 commit into from Jun 13, 2022

Conversation

svenklemm
Copy link
Member

Coverity warned about usage of pass by value in this instance so
we switch it to pass by reference to reduce the amount of copying
required for the function call.

@svenklemm svenklemm requested a review from a team as a code owner June 13, 2022 06:37
@svenklemm svenklemm requested review from erimatnor, konskov, gayyappan, akuzm, fabriziomello, jnidzwetzki, mfundul, nikkhils and pmwkaa and removed request for a team June 13, 2022 06:37
@svenklemm svenklemm self-assigned this Jun 13, 2022
Copy link
Contributor

@mkindahl mkindahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like this is only done to avoid the warning, not because it is actually a good idea. Suggest this wording:

Passing structures by value in function calls copies the entire structure, which is inefficient, so we switch it to pass by reference to reduce the amount of copying required.

@@ -117,11 +117,11 @@ is_valid_scalar_space_constraint(ScalarArrayOpExpr *op, List *rtable)
}

static FuncExpr *
make_partfunc_call(PartitioningFunc partfunc, List *args, Oid inputcollid)
make_partfunc_call(PartitioningFunc *partfunc, List *args, Oid inputcollid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the intention is to only read the data, it is good to encode this in the signature.

Suggested change
make_partfunc_call(PartitioningFunc *partfunc, List *args, Oid inputcollid)
make_partfunc_call(const PartitioningFunc *partfunc, List *args, Oid inputcollid)

@codecov
Copy link

codecov bot commented Jun 13, 2022

Codecov Report

Merging #4438 (0c8824b) into main (f72a277) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4438   +/-   ##
=======================================
  Coverage   90.85%   90.85%           
=======================================
  Files         221      221           
  Lines       40731    40731           
=======================================
  Hits        37006    37006           
  Misses       3725     3725           
Impacted Files Coverage Δ
src/cache_invalidate.c 91.48% <ø> (ø)
src/chunk.c 94.30% <ø> (ø)
src/cross_module_fn.c 69.28% <ø> (ø)
src/debug_point.c 93.42% <ø> (ø)
src/extension_utils.c 95.45% <ø> (ø)
src/planner/agg_bookend.c 93.16% <ø> (ø)
src/process_utility.c 94.50% <ø> (ø)
tsl/src/data_node.c 95.39% <ø> (ø)
tsl/src/nodes/decompress_chunk/decompress_chunk.c 95.16% <ø> (ø)
src/planner/space_constraint.c 94.61% <100.00%> (+0.04%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 308ce8c...0c8824b. Read the comment docs.

Refactor make_partfunc_call to only accept fnoid and rettype instead
of PartitioningFunc which also gets rid of a coverity warning about
that parameter being passed by value instead of reference because
that parameter was longer than 128 bytes.
@svenklemm svenklemm merged commit 1ac06c7 into timescale:main Jun 13, 2022
@svenklemm svenklemm added this to the TimescaleDB 2.7.1 milestone Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants