fix unwanted copies of return values - #185
Conversation
|
Edit: Thinking about this a bit more this was probably supposed to guard against the config hashmap getting modified. I cleaned this up in a couple of ways:
|
|
Really sorry for the delay, team has been really busy. Promise to take a look as fast as we can! |
|
Max Bachmann (@maxbachmann) just one minor note: The PR description ("supposed to return a const reference") is slightly misleading — the fix actually makes them return non-const values by value, which is the correct approach. |
|
The code looks correct to me and I verified that there are no compilation issues. |
There was a problem hiding this comment.
Pull request overview
Updates the C++ GSDK public API return types to avoid top-level const on return-by-value results, improving usability (callers can mutate the returned value) and enabling move semantics where applicable.
Changes:
- Remove top-level
constfrom return-by-value APIs (getConfigSettings,getLogsDirectory,getSharedContentDirectory) in the public header and implementation. - Avoid an extra copy of
m_configSettingsinsidegetLogsDirectory/getSharedContentDirectoryby referencing the internal map under the config mutex.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cpp/cppsdk/gsdk.h | Updates public API signatures to remove top-level const on return-by-value types. |
| cpp/cppsdk/gsdk.cpp | Matches updated signatures and reduces internal copying when reading config values. |
|
merging, thanks for the contribution Max Bachmann (@maxbachmann) ! |
d864af0
into
PlayFab:main
* fix unwanted string copy * fix more occurences and follow code formatting * fix return of local variable
Update public API return types to avoid returning by const value. This improves usability since callers can modify or move the returned value.
In addition this avoids an unnecessary copy of the m_configSettings hashmap while under the config mutex