googleapis / googleapis/google-cloud-cpp
Optimize initial `OptionSpan`
- Lenguaje dominante
- C++
- Estrellas
- 659
- Forks
- 462
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 89
Descripción
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_;
};
```
Guía de contribución
Línea de trabajo
Start by tracing how each *Client constructs OptionsSpan and how Options and ImmutableOptions currently store and retrieve values. Evaluate the proposed OptionsImpl and shared fallback design against the existing copy behavior; done means the initial options avoid the implicit copy while preserving option lookup semantics.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp
- Área
- backend-api-design, performance
- Tipo de issue
- Refactorización
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 30/100