mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-15 10:14:56 +08:00
Remove redundant copying of std::vectors
Usage of initializer list in for loop to iterate over heavy types has bad consequences. std::initialize_list is only a view and its data is silently created as T[N]. Therefore, if someone uses std::vector with it, it will cause deep-copying of the elements. This change introduces usage of pointers on std::initializer_list to perform a shallow-copy of an addresses. Furthermore, it adds const references in few places, where copy is not needed. Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3778a371fd
commit
44e1f1ba4b
@@ -161,7 +161,7 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t productConfig, NEO::Hard
|
||||
return retVal;
|
||||
}
|
||||
|
||||
auto deviceAotMap = productConfigHelper->getDeviceAotInfo();
|
||||
const auto &deviceAotMap = productConfigHelper->getDeviceAotInfo();
|
||||
for (auto &deviceConfig : deviceAotMap) {
|
||||
if (deviceConfig.aotConfig.ProductConfig == productConfig) {
|
||||
hwInfo = *deviceConfig.hwInfo;
|
||||
|
||||
@@ -110,10 +110,10 @@ class OclocArgHelper {
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
static auto getArgsWithoutDuplicate(Args... args) {
|
||||
static auto getArgsWithoutDuplicate(const Args &...args) {
|
||||
std::vector<NEO::ConstStringRef> out{};
|
||||
for (const auto &acronyms : {args...}) {
|
||||
for (const auto &acronym : acronyms) {
|
||||
for (const auto *acronyms : {std::addressof(args)...}) {
|
||||
for (const auto &acronym : *acronyms) {
|
||||
if (!std::any_of(out.begin(), out.end(), findDuplicate(acronym))) {
|
||||
out.push_back(acronym);
|
||||
}
|
||||
@@ -123,10 +123,10 @@ class OclocArgHelper {
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
static auto createStringForArgs(Args... args) {
|
||||
static auto createStringForArgs(const Args &...args) {
|
||||
std::ostringstream os;
|
||||
for (const auto &acronyms : {args...}) {
|
||||
for (const auto &acronym : acronyms) {
|
||||
for (const auto *acronyms : {std::addressof(args)...}) {
|
||||
for (const auto &acronym : *acronyms) {
|
||||
if (os.tellp())
|
||||
os << ", ";
|
||||
os << acronym.str();
|
||||
|
||||
@@ -118,8 +118,8 @@ void DebugZebinCreator::applyRelocations() {
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &relocations : {elf.getDebugInfoRelocations(), elf.getRelocations()}) {
|
||||
for (const auto &reloc : relocations) {
|
||||
for (const auto *relocations : {&elf.getDebugInfoRelocations(), &elf.getRelocations()}) {
|
||||
for (const auto &reloc : *relocations) {
|
||||
auto relocType = static_cast<RELOC_TYPE_ZEBIN>(reloc.relocType);
|
||||
if (isRelocTypeSupported(relocType) == false) {
|
||||
continue;
|
||||
|
||||
@@ -451,8 +451,8 @@ DG2TEST_F(ProductConfigTests, givenDg2G10DeviceIdWhenDifferentRevisionIsPassedTh
|
||||
}
|
||||
|
||||
DG2TEST_F(ProductConfigTests, givenDg2DeviceIdWhenIncorrectRevisionIsPassedThenCorrectProductConfigIsReturned) {
|
||||
for (const auto &dg2 : {dg2G10DeviceIds, dg2G11DeviceIds}) {
|
||||
for (const auto &deviceId : dg2) {
|
||||
for (const auto *dg2 : {&dg2G10DeviceIds, &dg2G11DeviceIds}) {
|
||||
for (const auto &deviceId : *dg2) {
|
||||
hwInfo.platform.usDeviceID = deviceId;
|
||||
hwInfo.platform.usRevId = CommonConstants::invalidRevisionID;
|
||||
productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo);
|
||||
|
||||
Reference in New Issue
Block a user