[SERVER-80480] [CQF] Avoid implicit copy from PolyValue::reference_type Created: 28/Aug/23  Updated: 29/Oct/23  Resolved: 15/Sep/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Task Priority: Major - P3
Reporter: David Percy Assignee: David Percy
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: QO 2023-09-04, QO 2023-09-18
Participants:

 Description   

PolyValue::reference_type has an implicit conversion to PolyValue, which has to deep copy. This interacts with visit() and transport(), and is causing some unintentional deep copying, for example in several of the CE transports.



 Comments   
Comment by Githook User [ 15/Sep/23 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-80480 Avoid implicit copy of PolyValue from reference_type

Previously we had an implicit constructor, 'PolyValue(const Reference&)'.
This resulted in some hard to spot deep copies, and counterintuitive
behavior where adding '.ref()' would force copying where omitting
'.ref()' would not have needed to copy.

This commit reverses that default: the expensive deep-copying
constructor is explicit, and the cheap 'Reference(const PolyValue&)'
constructor is implicit. Passing a value where only a view is required
is cheap and implicit; creating a new value given only a view is
expensive, and explicit.
Branch: master
https://github.com/mongodb/mongo/commit/2e2149c8bcc6cf4a4892ac5be6c150949808ae18

Comment by David Percy [ 05/Sep/23 ]

Edited this ticket to be just about the implicit copies, not the const behavior.

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