Back out clearly inconsequential/useless .reserve() calls

This commit is contained in:
Henrik Rydgård 2023-12-29 08:27:56 +01:00
parent c97d5ef23f
commit 126d88ecfc
25 changed files with 14 additions and 61 deletions

View File

@ -748,7 +748,6 @@ InputLayout *D3D11DrawContext::CreateInputLayout(const InputLayoutDesc &desc) {
inputLayout->desc = desc;
// Translate to D3D11 elements;
inputLayout->elements.reserve(desc.attributes.size());
for (size_t i = 0; i < desc.attributes.size(); i++) {
D3D11_INPUT_ELEMENT_DESC el;
el.AlignedByteOffset = desc.attributes[i].offset;
@ -1143,7 +1142,6 @@ Pipeline *D3D11DrawContext::CreateGraphicsPipeline(const PipelineDesc &desc, con
std::vector<D3D11ShaderModule *> shaders;
D3D11ShaderModule *vshader = nullptr;
shaders.reserve(desc.shaders.size());
for (auto iter : desc.shaders) {
iter->AddRef();

View File

@ -11,7 +11,6 @@ static std::set<GPUMemoryManager *> g_pushBuffers;
std::vector<GPUMemoryManager *> GetActiveGPUMemoryManagers() {
std::vector<GPUMemoryManager *> buffers;
std::lock_guard<std::mutex> guard(g_pushBufferListMutex);
buffers.reserve(g_pushBuffers.size());
for (auto iter : g_pushBuffers) {
buffers.push_back(iter);
}

View File

@ -1435,7 +1435,6 @@ void OpenGLInputLayout::Compile(const InputLayoutDesc &desc) {
stride = desc.stride;
std::vector<GLRInputLayout::Entry> entries;
entries.reserve(desc.attributes.size());
for (auto &attr : desc.attributes) {
GLRInputLayout::Entry entry;
entry.location = attr.location;

View File

@ -38,7 +38,6 @@ static const double PUSH_GARBAGE_COLLECTION_DELAY = 10.0;
VulkanPushPool::VulkanPushPool(VulkanContext *vulkan, const char *name, size_t originalBlockSize, VkBufferUsageFlags usage)
: vulkan_(vulkan), name_(name), originalBlockSize_(originalBlockSize), usage_(usage) {
RegisterGPUMemoryManager(this);
blocks_.reserve(VulkanContext::MAX_INFLIGHT_FRAMES);
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
blocks_.push_back(CreateBlock(originalBlockSize));
blocks_.back().original = true;

View File

@ -92,7 +92,6 @@ bool VulkanQueueRunner::CreateSwapchain(VkCommandBuffer cmdInit) {
return false;
}
swapchainImages_.reserve(swapchainImageCount_);
for (uint32_t i = 0; i < swapchainImageCount_; i++) {
SwapchainImageData sc_buffer{};
sc_buffer.image = swapchainImages[i];

View File

@ -43,7 +43,6 @@ std::vector<InputMapping> tabRightKeys;
static std::unordered_map<InputDeviceID, int> uiFlipAnalogY;
static void AppendKeys(std::vector<InputMapping> &keys, const std::vector<InputMapping> &newKeys) {
keys.reserve(newKeys.size());
for (auto iter = newKeys.begin(); iter != newKeys.end(); ++iter) {
keys.push_back(*iter);
}

View File

@ -156,7 +156,6 @@ Draw::Texture *CreateTextureFromTempImage(Draw::DrawContext *draw, const TempIma
desc.mipLevels = generateMips ? potentialLevels : image.numLevels;
desc.generateMips = generateMips && potentialLevels > image.numLevels;
desc.tag = name;
desc.initData.reserve(image.numLevels);
for (int i = 0; i < image.numLevels; i++) {
desc.initData.push_back(image.levels[i]);
}

View File

@ -1891,7 +1891,6 @@ uint32_t getLocalIp(int sock) {
static std::vector<std::pair<uint32_t, uint32_t>> InitPrivateIPRanges() {
struct sockaddr_in saNet {}, saMask{};
std::vector<std::pair<uint32_t, uint32_t>> ip_ranges;
ip_ranges.reserve(5);
if (1 == inet_pton(AF_INET, "192.168.0.0", &(saNet.sin_addr)) && 1 == inet_pton(AF_INET, "255.255.0.0", &(saMask.sin_addr)))
ip_ranges.push_back({saNet.sin_addr.s_addr, saMask.sin_addr.s_addr});

View File

@ -386,7 +386,6 @@ void Arm64JitBackend::CompIR_ValidateAddress(IRInst inst) {
ANDI2R(SCRATCH1, SCRATCH1, 0x3FFFFFFF, SCRATCH2);
std::vector<FixupBranch> validJumps;
validJumps.reserve(3);
FixupBranch unaligned;
if (alignment == 2) {

View File

@ -1415,7 +1415,6 @@ skip:
std::vector<MIPSGPReg> GetOutputRegs(MIPSOpcode op) {
std::vector<MIPSGPReg> vec;
vec.reserve(3);
MIPSInfo info = MIPSGetInfo(op);
if (info & OUT_RD) vec.push_back(MIPS_GET_RD(op));
if (info & OUT_RT) vec.push_back(MIPS_GET_RT(op));

View File

@ -83,7 +83,6 @@ bool RiscVJitBackend::CompileBlock(IRBlock *block, int block_num, bool preload)
regs_.Start(block);
std::vector<const u8 *> addresses;
addresses.reserve(block->GetNumInstructions());
for (int i = 0; i < block->GetNumInstructions(); ++i) {
const IRInst &inst = block->GetInstructions()[i];
regs_.SetIRIndex(i);

View File

@ -904,7 +904,7 @@ void Jit::CheckMemoryBreakpoint(int instructionOffset, MIPSGPReg rs, int offset)
SetJumpTarget(skipCheck);
}
} else {
const auto &memchecks = CBreakPoints::GetMemCheckRanges(isWrite);
const auto memchecks = CBreakPoints::GetMemCheckRanges(isWrite);
bool possible = !memchecks.empty();
if (!possible)
return;

View File

@ -455,7 +455,6 @@ void JitSafeMemFuncs::CreateWriteFunc(int bits, const void *fallbackFunc) {
void JitSafeMemFuncs::CheckDirectEAX() {
// Clear any cache/kernel bits.
AND(32, R(EAX), Imm32(0x3FFFFFFF));
skips_.reserve(3);
CMP(32, R(EAX), Imm32(PSP_GetUserMemoryEnd()));
FixupBranch tooHighRAM = J_CC(CC_AE);

View File

@ -147,7 +147,7 @@ void X64JitBackend::CompIR_Breakpoint(IRInst inst) {
}
bool isWrite = MIPSAnalyst::IsOpMemoryWrite(checkedPC);
const auto &memchecks = CBreakPoints::GetMemCheckRanges(isWrite);
const auto memchecks = CBreakPoints::GetMemCheckRanges(isWrite);
// We can trivially skip if there are no checks for this type (i.e. read vs write.)
if (memchecks.empty())
break;
@ -159,7 +159,6 @@ void X64JitBackend::CompIR_Breakpoint(IRInst inst) {
FlushAll();
std::vector<FixupBranch> hitChecks;
hitChecks.reserve(memchecks.size());
for (const auto &it : memchecks) {
if (it.end != 0) {
CMP(32, R(SCRATCH1), Imm32(it.start - size));
@ -396,7 +395,6 @@ void X64JitBackend::CompIR_ValidateAddress(IRInst inst) {
AND(32, R(SCRATCH1), Imm32(0x3FFFFFFF));
std::vector<FixupBranch> validJumps;
validJumps.reserve(3);
FixupBranch unaligned;
if (alignment != 1) {

View File

@ -9,7 +9,6 @@ GameDB g_gameDB;
static void SplitCSVLine(const std::string_view str, std::vector<std::string_view> &result) {
result.clear();
result.reserve(str.size() + 1);
int indexCommaToLeftOfColumn = 0;
int indexCommaToRightOfColumn = -1;

View File

@ -75,7 +75,6 @@ VertexDecoder *DrawEngineCommon::GetVertexDecoder(u32 vtype) {
std::vector<std::string> DrawEngineCommon::DebugGetVertexLoaderIDs() {
std::vector<std::string> ids;
ids.reserve(decoderMap_.size());
decoderMap_.Iterate([&](const uint32_t vtype, VertexDecoder *decoder) {
std::string id;
id.resize(sizeof(vtype));

View File

@ -72,7 +72,6 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
std::vector<const char*> extensions;
if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) {
extensions.reserve(4);
if (stencilToAlpha == REPLACE_ALPHA_DUALSOURCE && gl_extensions.EXT_blend_func_extended) {
extensions.push_back("#extension GL_EXT_blend_func_extended : require");
}

View File

@ -67,8 +67,6 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu
}
std::vector<VaryingDef> varyings, outVaryings;
varyings.reserve(4);
outVaryings.reserve(4);
if (id.Bit(GS_BIT_DO_TEXTURE)) {
varyings.push_back(VaryingDef{ "vec3", "v_texcoord", Draw::SEM_TEXCOORD0, 0, "highp" });

View File

@ -251,7 +251,6 @@ std::vector<std::string> ShaderManagerD3D11::DebugGetShaderIDs(DebugShaderType t
switch (type) {
case SHADER_TYPE_VERTEX:
{
ids.reserve(vsCache_.size());
for (auto iter : vsCache_) {
iter.first.ToString(&id);
ids.push_back(id);
@ -260,7 +259,6 @@ std::vector<std::string> ShaderManagerD3D11::DebugGetShaderIDs(DebugShaderType t
}
case SHADER_TYPE_FRAGMENT:
{
ids.reserve(fsCache_.size());
for (auto iter : fsCache_) {
iter.first.ToString(&id);
ids.push_back(id);

View File

@ -666,23 +666,17 @@ std::vector<std::string> ShaderManagerDX9::DebugGetShaderIDs(DebugShaderType typ
std::vector<std::string> ids;
switch (type) {
case SHADER_TYPE_VERTEX:
{
ids.reserve(vsCache_.size());
for (auto iter : vsCache_) {
iter.first.ToString(&id);
ids.push_back(id);
}
}
break;
break;
case SHADER_TYPE_FRAGMENT:
{
ids.reserve(fsCache_.size());
for (auto iter : fsCache_) {
iter.first.ToString(&id);
ids.push_back(id);
}
}
break;
break;
}
return ids;
}

View File

@ -103,7 +103,6 @@ void DrawEngineGLES::InitDeviceObjects() {
int stride = sizeof(TransformedVertex);
std::vector<GLRInputLayout::Entry> entries;
entries.reserve(5);
entries.push_back({ ATTR_POSITION, 4, GL_FLOAT, GL_FALSE, offsetof(TransformedVertex, x) });
entries.push_back({ ATTR_TEXCOORD, 3, GL_FLOAT, GL_FALSE, offsetof(TransformedVertex, u) });
entries.push_back({ ATTR_COLOR0, 4, GL_UNSIGNED_BYTE, GL_TRUE, offsetof(TransformedVertex, color0) });

View File

@ -914,24 +914,18 @@ std::vector<std::string> ShaderManagerGLES::DebugGetShaderIDs(DebugShaderType ty
std::vector<std::string> ids;
switch (type) {
case SHADER_TYPE_VERTEX:
{
ids.reserve(vsCache_.size());
vsCache_.Iterate([&](const VShaderID &id, Shader *shader) {
std::string idstr;
id.ToString(&idstr);
ids.push_back(idstr);
});
}
vsCache_.Iterate([&](const VShaderID &id, Shader *shader) {
std::string idstr;
id.ToString(&idstr);
ids.push_back(idstr);
});
break;
case SHADER_TYPE_FRAGMENT:
{
ids.reserve(fsCache_.size());
fsCache_.Iterate([&](const FShaderID &id, Shader *shader) {
std::string idstr;
id.ToString(&idstr);
ids.push_back(idstr);
});
}
fsCache_.Iterate([&](const FShaderID &id, Shader *shader) {
std::string idstr;
id.ToString(&idstr);
ids.push_back(idstr);
});
break;
default:
break;

View File

@ -393,35 +393,26 @@ std::vector<std::string> ShaderManagerVulkan::DebugGetShaderIDs(DebugShaderType
std::vector<std::string> ids;
switch (type) {
case SHADER_TYPE_VERTEX:
{
ids.reserve(vsCache_.size());
vsCache_.Iterate([&](const VShaderID &id, VulkanVertexShader *shader) {
std::string idstr;
id.ToString(&idstr);
ids.push_back(idstr);
});
break;
}
case SHADER_TYPE_FRAGMENT:
{
ids.reserve(fsCache_.size());
fsCache_.Iterate([&](const FShaderID &id, VulkanFragmentShader *shader) {
std::string idstr;
id.ToString(&idstr);
ids.push_back(idstr);
});
break;
}
case SHADER_TYPE_GEOMETRY:
{
ids.reserve(gsCache_.size());
gsCache_.Iterate([&](const GShaderID &id, VulkanGeometryShader *shader) {
std::string idstr;
id.ToString(&idstr);
ids.push_back(idstr);
});
break;
}
default:
break;
}

View File

@ -187,7 +187,6 @@ void SamplerCache::DeviceRestore(VulkanContext *vulkan) {
std::vector<std::string> SamplerCache::DebugGetSamplerIDs() const {
std::vector<std::string> ids;
ids.reserve(cache_.size());
cache_.Iterate([&](const SamplerCacheKey &id, VkSampler sampler) {
std::string idstr;
id.ToString(&idstr);

View File

@ -850,7 +850,6 @@ std::vector<u32> CtrlMemView::searchString(const std::string &searchQuery) {
return searchResAddrs;
std::vector<std::pair<u32, u32>> memoryAreas;
memoryAreas.reserve(3);
memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd());
// Ignore the video memory mirrors.
memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000);
@ -901,7 +900,6 @@ void CtrlMemView::search(bool continueSearch) {
}
std::vector<std::pair<u32, u32>> memoryAreas;
memoryAreas.reserve(3);
// Ignore the video memory mirrors.
memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000);
memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd());