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

Pass std::string_view by value not by ref #33699

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion impeller/compiler/reflector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static std::string ToString(CompilerBackend::Type type) {
}

std::shared_ptr<fml::Mapping> Reflector::InflateTemplate(
const std::string_view& tmpl) const {
std::string_view tmpl) const {
inja::Environment env;
env.set_trim_blocks(true);
env.set_lstrip_blocks(true);
Expand Down
3 changes: 1 addition & 2 deletions impeller/compiler/reflector.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ class Reflector {

std::shared_ptr<fml::Mapping> GenerateReflectionCC() const;

std::shared_ptr<fml::Mapping> InflateTemplate(
const std::string_view& tmpl) const;
std::shared_ptr<fml::Mapping> InflateTemplate(std::string_view tmpl) const;

std::optional<nlohmann::json::object_t> ReflectResource(
const spirv_cross::Resource& resource) const;
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/gles/shader_library_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool ShaderLibraryGLES::IsValid() const {

// |ShaderLibrary|
std::shared_ptr<const ShaderFunction> ShaderLibraryGLES::GetFunction(
const std::string_view& name,
std::string_view name,
ShaderStage stage) {
const auto key = ShaderKey{name, stage};
if (auto found = functions_.find(key); found != functions_.end()) {
Expand Down
5 changes: 2 additions & 3 deletions impeller/renderer/backend/gles/shader_library_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class ShaderLibraryGLES final : public ShaderLibrary {
std::vector<std::shared_ptr<fml::Mapping>> shader_libraries);

// |ShaderLibrary|
std::shared_ptr<const ShaderFunction> GetFunction(
const std::string_view& name,
ShaderStage stage) override;
std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,
ShaderStage stage) override;

FML_DISALLOW_COPY_AND_ASSIGN(ShaderLibraryGLES);
};
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/gles/texture_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool TextureGLES::IsValid() const {
}

// |Texture|
void TextureGLES::SetLabel(const std::string_view& label) {
void TextureGLES::SetLabel(std::string_view label) {
reactor_->SetDebugLabel(handle_, std::string{label.data(), label.size()});
}

Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/gles/texture_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TextureGLES final : public Texture,
bool is_wrapped);

// |Texture|
void SetLabel(const std::string_view& label) override;
void SetLabel(std::string_view label) override;

// |Texture|
bool OnSetContents(const uint8_t* contents,
Expand Down
5 changes: 2 additions & 3 deletions impeller/renderer/backend/metal/shader_library_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ class ShaderLibraryMTL final : public ShaderLibrary {
ShaderLibraryMTL(NSArray<id<MTLLibrary>>* libraries);

// |ShaderLibrary|
std::shared_ptr<const ShaderFunction> GetFunction(
const std::string_view& name,
ShaderStage stage) override;
std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,
ShaderStage stage) override;

FML_DISALLOW_COPY_AND_ASSIGN(ShaderLibraryMTL);
};
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/metal/shader_library_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

std::shared_ptr<const ShaderFunction> ShaderLibraryMTL::GetFunction(
const std::string_view& name,
std::string_view name,
ShaderStage stage) {
if (!IsValid()) {
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/metal/texture_mtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TextureMTL final : public Texture,
bool is_valid_ = false;

// |Texture|
void SetLabel(const std::string_view& label) override;
void SetLabel(std::string_view label) override;

// |Texture|
bool OnSetContents(const uint8_t* contents,
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/metal/texture_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

TextureMTL::~TextureMTL() = default;

void TextureMTL::SetLabel(const std::string_view& label) {
void TextureMTL::SetLabel(std::string_view label) {
[texture_ setLabel:@(label.data())];
}

Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/shader_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct ShaderKey {
std::string name;
ShaderStage stage = ShaderStage::kUnknown;

ShaderKey(const std::string_view& p_name, ShaderStage p_stage)
ShaderKey(std::string_view p_name, ShaderStage p_stage)
: name({p_name.data(), p_name.size()}), stage(p_stage) {}

struct Hash {
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/shader_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ShaderLibrary {
virtual bool IsValid() const = 0;

virtual std::shared_ptr<const ShaderFunction> GetFunction(
const std::string_view& name,
std::string_view name,
ShaderStage stage) = 0;

protected:
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Texture {
public:
virtual ~Texture();

virtual void SetLabel(const std::string_view& label) = 0;
virtual void SetLabel(std::string_view label) = 0;

[[nodiscard]] bool SetContents(const uint8_t* contents,
size_t length,
Expand Down