Using reserve if possible

This commit is contained in:
Herman Semenov 2023-12-12 15:13:43 +03:00
parent 60402909f8
commit de80cc3883
4 changed files with 6 additions and 1 deletions

View File

@ -225,7 +225,6 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
off.settings[i].maxValue = 1.0f;
off.settings[i].step = 0.01f;
}
shaderInfo.insert(shaderInfo.begin(), off);
TextureShaderInfo textureOff{};
textureOff.name = "Off";
@ -233,6 +232,8 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector<Path> &direct
textureShaderInfo.insert(textureShaderInfo.begin(), textureOff);
// We always want the not visible ones at the end. Makes menus easier.
shaderInfo.reserve(notVisible.size() + 1);
shaderInfo.insert(shaderInfo.begin(), off);
for (const auto &info : notVisible) {
appendShader(info);
}

View File

@ -522,6 +522,7 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference
basist::ktx2_transcoder_state transcodeState; // Each thread needs one of these.
transcoder.start_transcoding();
levels_.reserve(numMips);
for (int i = 0; i < numMips; i++) {
std::vector<uint8_t> &out = data_[mipLevel + i];
@ -574,6 +575,7 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference
data_.resize(numMips);
// A DDS File can contain multiple mipmaps.
levels_.reserve(numMips);
for (int i = 0; i < numMips; i++) {
std::vector<uint8_t> &out = data_[mipLevel + i];

View File

@ -1141,6 +1141,7 @@ bool ShaderManagerGLES::LoadCache(File::IOFile &f) {
}
}
linkedShaderCache_.reserve(pending.link.size() - pending.linkPos);
for (size_t &i = pending.linkPos; i < pending.link.size(); i++) {
const VShaderID &vsid = pending.link[i].first;
const FShaderID &fsid = pending.link[i].second;

View File

@ -1606,6 +1606,7 @@ std::vector<GPUDebugOp> GPUCommon::DissassembleOpRange(u32 startpc, u32 endpc) {
// Don't trigger a pause.
u32 prev = Memory::IsValidAddress(startpc - 4) ? Memory::Read_U32(startpc - 4) : 0;
result.reserve((endpc - startpc) / 4);
for (u32 pc = startpc; pc < endpc; pc += 4) {
u32 op = Memory::IsValidAddress(pc) ? Memory::Read_U32(pc) : 0;
GeDisassembleOp(pc, op, prev, buffer, sizeof(buffer));