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:
@@ -22,7 +22,6 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
@@ -554,9 +553,9 @@ void Session::FillSimpleMessage(uint32_t duration, uint32_t control,
|
||||
if (global_features.api_version >= 12) {
|
||||
// For version 12 and above, we require OEMCrypto to handle kcNN for all
|
||||
// licenses.
|
||||
std::stringstream stream;
|
||||
stream << "kc" << global_features.api_version;
|
||||
memcpy(license_.keys[i].control.verification, stream.str().c_str(), 4);
|
||||
std::string kcVersion =
|
||||
"kc" + std::to_string(global_features.api_version);
|
||||
memcpy(license_.keys[i].control.verification, kcVersion.c_str(), 4);
|
||||
} else if (control & wvoec::kControlSecurityPatchLevelMask) {
|
||||
// For versions before 12, we require the special key control block only
|
||||
// when there are newer features present.
|
||||
@@ -598,9 +597,9 @@ void Session::FillSimpleEntitlementMessage(
|
||||
if (global_features.api_version >= 12) {
|
||||
// For version 12 and above, we require OEMCrypto to handle kcNN for all
|
||||
// licenses.
|
||||
std::stringstream stream;
|
||||
stream << "kc" << global_features.api_version;
|
||||
memcpy(license_.keys[i].control.verification, stream.str().c_str(), 4);
|
||||
std::string kcVersion =
|
||||
"kc" + std::to_string(global_features.api_version);
|
||||
memcpy(license_.keys[i].control.verification, kcVersion.c_str(), 4);
|
||||
} else if (control & wvoec::kControlSecurityPatchLevelMask) {
|
||||
// For versions before 12, we require the special key control block only
|
||||
// when there are newer features present.
|
||||
@@ -631,10 +630,10 @@ void Session::FillRefreshMessage(size_t key_count, uint32_t control_bits,
|
||||
if (global_features.api_version >= 12) {
|
||||
// For version 12 and above, we require OEMCrypto to handle kcNN for all
|
||||
// licenses.
|
||||
std::stringstream stream;
|
||||
stream << "kc" << global_features.api_version;
|
||||
std::string kcVersion =
|
||||
"kc" + std::to_string(global_features.api_version);
|
||||
memcpy(encrypted_license().keys[i].control.verification,
|
||||
stream.str().c_str(), 4);
|
||||
kcVersion.c_str(), 4);
|
||||
} else {
|
||||
// For versions before 12, we require the special key control block only
|
||||
// when there are newer features present.
|
||||
|
||||
Reference in New Issue
Block a user