Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Avoid stringstream usage in CreateUniformMemberKey #39606

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions impeller/renderer/backend/gles/buffer_bindings_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>

#include "impeller/base/config.h"
Expand Down Expand Up @@ -70,18 +69,21 @@ static std::string NormalizeUniformKey(const std::string& key) {
return result;
}

static std::string CreateUnifiormMemberKey(const std::string& struct_name,
const std::string& member,
bool is_array) {
std::stringstream stream;
stream << struct_name << "." << member;
static std::string CreateUniformMemberKey(const std::string& struct_name,
const std::string& member,
bool is_array) {
std::string result;
result.reserve(struct_name.length() + member.length() + (is_array ? 4 : 1));
result += struct_name;
result += '.';
result += member;
if (is_array) {
stream << "[0]";
result += "[0]";
}
return NormalizeUniformKey(stream.str());
return NormalizeUniformKey(result);
}

static std::string CreateUnifiormMemberKey(
static std::string CreateUniformMemberKey(
const std::string& non_struct_member) {
return NormalizeUniformKey(non_struct_member);
}
Expand Down Expand Up @@ -216,7 +218,7 @@ bool BufferBindingsGLES::BindUniformBuffer(const ProcTableGLES& gl,
size_t element_count = member.array_elements.value_or(1);

const auto member_key =
CreateUnifiormMemberKey(metadata->name, member.name, element_count > 1);
CreateUniformMemberKey(metadata->name, member.name, element_count > 1);
const auto location = uniform_locations_.find(member_key);
if (location == uniform_locations_.end()) {
// The list of uniform locations only contains "active" uniforms that are
Expand Down Expand Up @@ -318,7 +320,7 @@ bool BufferBindingsGLES::BindTextures(const ProcTableGLES& gl,
return false;
}

const auto uniform_key = CreateUnifiormMemberKey(texture.second.isa->name);
const auto uniform_key = CreateUniformMemberKey(texture.second.isa->name);
auto uniform = uniform_locations_.find(uniform_key);
if (uniform == uniform_locations_.end()) {
VALIDATION_LOG << "Could not find uniform for key: " << uniform_key;
Expand Down