Don't Use StringStream When It's Overkill

(This is a merge of http://go/wvgerrit/76063)

Now that we have C++11, many places that do string formatting or parsing
can be replaced with std::to_string() or one of the std::sto*() family
of functions. This patch updates places that do simple stringifying or
parsing to use these functions. Some parts of the code are left
untouched because they were using StringStream to do more complex
actions, such as constructing more complex output or checking the status
of the parsing.

Bug: 120599938
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I482dc234ecd7c6014fa9b6874387ff51e04b772f
This commit is contained in:
John W. Bruce
2019-04-17 17:46:31 -07:00
parent 7ab472a3d8
commit 5ea429ee2b
10 changed files with 100 additions and 124 deletions

View File

@@ -12,7 +12,6 @@
#include <endian.h>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
@@ -114,8 +113,8 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
if (isCdmResponseTypeSuccess(res) &&
info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
OEMCrypto_SESSION oecSessionId;
istringstream(info[QUERY_KEY_OEMCRYPTO_SESSION_ID]) >> oecSessionId;
OEMCrypto_SESSION oecSessionId =
std::stoul(info[QUERY_KEY_OEMCRYPTO_SESSION_ID]);
mCryptoSessions[cdmSessionId] = CryptoSession(oecSessionId);
success = true;
} else {

View File

@@ -10,6 +10,7 @@
#include <list>
#include <stdlib.h>
#include <string>
#include "WVDrmPlugin.h"
@@ -229,9 +230,8 @@ Status WVDrmPlugin::openSessionCommon(std::vector<uint8_t>& sessionId) {
if (isCdmResponseTypeSuccess(res) &&
info.count(wvcdm::QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
OEMCrypto_SESSION oecSessionId;
std::istringstream(
info[wvcdm::QUERY_KEY_OEMCRYPTO_SESSION_ID]) >> oecSessionId;
OEMCrypto_SESSION oecSessionId =
std::stoul(info[wvcdm::QUERY_KEY_OEMCRYPTO_SESSION_ID]);
mCryptoSessions[cdmSessionId] = CryptoSession(oecSessionId);
success = true;
} else {