Replace push_back with emplace_back to avoid unnecessary temporary co… #3663
+7
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
N/A
Description of changes:
Optimized vector insertions in TextToSpeechManager.cpp & ClientConfiguration.cpp by replacing push_back with emplace_back.
In EnumerateDevices(), OutputDevicePair is now constructed directly in the vector memory instead of creating a temporary and pushing it.
In ListAvailableVoices(), voice name/language pairs are now constructed directly in place, and the vector reserves capacity upfront to reduce reallocations.
In calculateAuthPreferences(), insertion happens with more optimal way.
These changes eliminate unnecessary temporaries, slightly improve performance, and adhere to modern C++ best practices.
No functional changes or API changes; fully backward-compatible.
Check all that applies:
Did a review by yourself.
Added proper tests to cover this PR. (Existing unit tests verify correctness; no new tests required.)
Checked if this PR is a breaking (APIs have been changed) change.
Checked if this PR will not introduce cross-platform inconsistent behavior.
Checked if this PR would require a ReadMe/Wiki update.
Check which platforms you have built SDK on to verify the correctness of this PR:
Linux
Windows
Android
MacOS
IOS
Other Platforms
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.