From d2fba40cb48c76ee3f246c7b17259c71d432f890 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Thu, 18 Jul 2019 22:21:55 +0200 Subject: [PATCH] Small improvements Its always better to reserve memory when we can for a vector. Also, STL implements a lot of algorithms, its better to use them in case someday you need to change it to something alike. Like reversing the copy, use transform instead, etc... --- dll/steam_inventory.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dll/steam_inventory.h b/dll/steam_inventory.h index 96ddcfe..2eec7fb 100644 --- a/dll/steam_inventory.h +++ b/dll/steam_inventory.h @@ -70,8 +70,8 @@ struct Steam_Inventory_Requests* new_inventory_result(bool full_query=true, cons request.inventory_result = result; request.full_query = full_query; if (pInstanceIDs && unCountInstanceIDs) { - for (int i = 0; i < unCountInstanceIDs; ++i) - request.instance_ids.push_back(pInstanceIDs[i]); + request.instance_ids.reserve(unCountInstanceIDs); + std::copy(pInstanceIDs, pInstanceIDs + unCountInstanceIDs, std::back_inserter(request.instance_ids)); } request.time_created = std::chrono::system_clock::now();