mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	cleanup
This commit is contained in:
		| @@ -44,17 +44,6 @@ bool parse_json(const std::string &data, const json_parse_t &f) { | |||||||
|   // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) |   // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) | ||||||
| } | } | ||||||
|  |  | ||||||
| // JsonBuilder implementation |  | ||||||
| JsonBuilder::JsonBuilder() |  | ||||||
|     : doc_( |  | ||||||
| #ifdef USE_PSRAM |  | ||||||
|           &allocator_ |  | ||||||
| #else |  | ||||||
|           nullptr |  | ||||||
| #endif |  | ||||||
|       ) { |  | ||||||
| } |  | ||||||
|  |  | ||||||
| std::string JsonBuilder::serialize() { | std::string JsonBuilder::serialize() { | ||||||
|   if (doc_.overflowed()) { |   if (doc_.overflowed()) { | ||||||
|     ESP_LOGE(TAG, "JSON document overflow"); |     ESP_LOGE(TAG, "JSON document overflow"); | ||||||
|   | |||||||
| @@ -46,8 +46,6 @@ bool parse_json(const std::string &data, const json_parse_t &f); | |||||||
| /// Builder class for creating JSON documents without lambdas | /// Builder class for creating JSON documents without lambdas | ||||||
| class JsonBuilder { | class JsonBuilder { | ||||||
|  public: |  public: | ||||||
|   JsonBuilder(); |  | ||||||
|  |  | ||||||
|   JsonObject root() { |   JsonObject root() { | ||||||
|     if (!root_created_) { |     if (!root_created_) { | ||||||
|       root_ = doc_.to<JsonObject>(); |       root_ = doc_.to<JsonObject>(); | ||||||
| @@ -61,8 +59,10 @@ class JsonBuilder { | |||||||
|  private: |  private: | ||||||
| #ifdef USE_PSRAM | #ifdef USE_PSRAM | ||||||
|   SpiRamAllocator allocator_;      // Just a regular member on the stack! |   SpiRamAllocator allocator_;      // Just a regular member on the stack! | ||||||
|  |   JsonDocument doc_{&allocator_};  // Initialize with allocator | ||||||
|  | #else | ||||||
|  |   JsonDocument doc_;  // Default initialization | ||||||
| #endif | #endif | ||||||
|   JsonDocument doc_; |  | ||||||
|   JsonObject root_; |   JsonObject root_; | ||||||
|   bool root_created_{false}; |   bool root_created_{false}; | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user