|
I think if there's a goal to move TransactionsUtil.deepCopyObject({}, cmdObj) to a more common place then we should attempt to unify its interface with the pattern of Object.extend({}, cmdObj, true /* deep */). As a bit of history/context, the original deepCopyObject() function was written for SERVER-35037 because custom types like DB and DBCollection have underlying C++ data (the Mongo connection object) and cannot be copied through enumerating over all properties on the object. The deepCopyObject() function was then moved to become TransactionsUtil.deepCopyObject() in SERVER-38937 because Object.extend() doesn't handle other custom types like BinData and NumberInt which have underlying C++ data. We don't actually need to make copies of those values because they are effectively immutable (as far as the underlying C++ data is concerned).
I'd be concerned about proliferating more usages of TransactionsUtil.deepCopyObject() we had made for expediency over doing SERVER-40425.
|