Replaces Resource's shared_ptr with unique_ptr (flutter/engine#56778)
A non-inconsequential amount of time is spent in ~shared_ptr for no reason in ~Resource <img width="1057" alt="Screenshot 2024-11-23 at 3 22 11â¯PM" src="https://github.com/user-attachments/assets/fba73908-2e43-4908-8008-ddd78fd77831"> [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
8fb4a66d39
commit
c1b6fd8c69
@ -29,7 +29,8 @@ namespace impeller {
|
||||
#endif // IMPELLER_DEBUG
|
||||
|
||||
template <class T>
|
||||
struct Resource {
|
||||
class Resource {
|
||||
public:
|
||||
using ResourceType = T;
|
||||
ResourceType resource;
|
||||
|
||||
@ -40,7 +41,7 @@ struct Resource {
|
||||
|
||||
Resource(const ShaderMetadata& metadata, ResourceType p_resource)
|
||||
: resource(p_resource),
|
||||
dynamic_metadata_(std::make_shared<ShaderMetadata>(metadata)) {}
|
||||
dynamic_metadata_(std::make_unique<ShaderMetadata>(metadata)) {}
|
||||
|
||||
const ShaderMetadata* GetMetadata() const {
|
||||
return dynamic_metadata_ ? dynamic_metadata_.get() : metadata_;
|
||||
@ -51,7 +52,7 @@ struct Resource {
|
||||
const ShaderMetadata* metadata_ = nullptr;
|
||||
|
||||
// Dynamically generated shader metadata.
|
||||
std::shared_ptr<const ShaderMetadata> dynamic_metadata_ = nullptr;
|
||||
std::unique_ptr<const ShaderMetadata> dynamic_metadata_ = nullptr;
|
||||
};
|
||||
|
||||
using BufferResource = Resource<BufferView>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user