googleapis / googleapis/google-cloud-cpp
Optimize initial `OptionSpan`
- Ngôn ngữ chính
- C++
- Star
- 659
- Fork
- 462
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 89
Mô tả
Every request in a `*Client` starts with something like:
```cc
google::cloud::internal::OptionsSpan span(std::move(options), options_);
```
The `options_` member variable never changes value. We should avoid the implicit copy from these options. If we can hold them as a `std::shared_ptr` then maybe `ImmutableOptions` can become a class that holds two `Options`, one by value (initialized via move) and a `std::shared_ptr<>` with the remaining values.
Something like:
```cc
class internal::OptionsImpl { // Similar to the Options class today
public:
template auto get() const { ... }
// has() and get() rolled into a single operation.
template std::pair find() const { ... }
};
class internal::ImmutableOptions {
public:
template auto get() const {
auto [has, value] = impl_.find();
if (has) return *value;
return fallback_.get();
}
// No set or unset member functions.
private:
OptionsImpl impl_;
std::shared_ptr fallback_;
};
class Options {
private:
OptionsImpl impl_;
};
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách theo dõi cách mỗi *Client tạo OptionsSpan và cách Options cùng ImmutableOptions hiện lưu trữ và truy xuất các giá trị. Đánh giá thiết kế OptionsImpl và fallback dùng chung được đề xuất dựa trên hành vi sao chép hiện có; công việc được xem là hoàn tất khi các tùy chọn ban đầu tránh được việc sao chép ngầm mà vẫn bảo toàn ngữ nghĩa tra cứu tùy chọn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- cpp
- Lĩnh vực
- backend-api-design, performance
- Loại issue
- Tái cấu trúc
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 30/100