[SERVER-68885] Coverity analysis defect 123452: AUTO_CAUSES_COPY Created: 17/Aug/22  Updated: 27/Oct/23  Resolved: 30/Aug/22

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Coverity Collector User Assignee: Backlog - Query Execution
Resolution: Works as Designed Votes: 0
Labels: coverity, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2022-08-17 at 9.54.41 AM.png    
Assigned Teams:
Query Execution
Participants:

 Description   

AUTO_CAUSES_COPY

Unnecessary object copies can affect performance. Using the auto keyword without an & causes a copy.
/src/mongo/s/write_ops/batched_command_response.cpp:209: AUTO_CAUSES_COPY 123452 Using the "auto" keyword without an "&" causes the copy of an object of type BSONElement.



 Comments   
Comment by Kyle Suarez [ 30/Aug/22 ]

After a lengthy discussion in #cxx-discuss we have concluded that because BSONElement is trivially copiable and <= 16 bytes, it will be passed via registers on all the relevant calling conventions. Closing this as "works as designed".

Generated at Thu Feb 08 06:11:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.