mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
preen
This commit is contained in:
@@ -175,8 +175,8 @@ void MDNSComponent::compile_records_(StaticVector<MDNSService, MDNS_SERVICE_COUN
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_MDNS_STORE_SERVICES
|
#ifdef USE_MDNS_STORE_SERVICES
|
||||||
// Copy to member variable if storage is enabled (verbose logging, OpenThread, or extra services)
|
// Move to member variable if storage is enabled (verbose logging, OpenThread, or extra services)
|
||||||
this->services_ = services;
|
this->services_ = std::move(services);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,32 +208,11 @@ template<typename T> class FixedVector {
|
|||||||
|
|
||||||
~FixedVector() { cleanup_(); }
|
~FixedVector() { cleanup_(); }
|
||||||
|
|
||||||
// Copy constructor - performs deep copy
|
// Disable copy operations - use std::move() to transfer ownership
|
||||||
FixedVector(const FixedVector &other) {
|
FixedVector(const FixedVector &) = delete;
|
||||||
if (other.size_ > 0) {
|
FixedVector &operator=(const FixedVector &) = delete;
|
||||||
init(other.size_);
|
|
||||||
for (size_t i = 0; i < other.size_; i++) {
|
|
||||||
push_back(other.data_[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy assignment operator - performs deep copy
|
// Enable move semantics
|
||||||
FixedVector &operator=(const FixedVector &other) {
|
|
||||||
if (this != &other) {
|
|
||||||
cleanup_();
|
|
||||||
reset_();
|
|
||||||
if (other.size_ > 0) {
|
|
||||||
init(other.size_);
|
|
||||||
for (size_t i = 0; i < other.size_; i++) {
|
|
||||||
push_back(other.data_[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable move semantics (allows use in move-only containers like std::vector)
|
|
||||||
FixedVector(FixedVector &&other) noexcept : data_(other.data_), size_(other.size_), capacity_(other.capacity_) {
|
FixedVector(FixedVector &&other) noexcept : data_(other.data_), size_(other.size_), capacity_(other.capacity_) {
|
||||||
other.reset_();
|
other.reset_();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user