Skip to content

Commit 7585c0f

Browse files
committed
Extract asString()
Before: 9874, 8736, 9694, 12634, 9970 After: 9802, 8736, 9630, 12588, 9910 Target: 9800, 8458, 9634, 12290, 9702
1 parent 8af2940 commit 7585c0f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/ArduinoJson/Object/ObjectImpl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ inline ObjectImpl::iterator ObjectImpl::findKey(TAdaptedString key) const {
3434
bool isKey = true;
3535
for (auto it = createIterator(); !it.done(); it.next(resources_)) {
3636
VariantImpl variant(it.data(), resources_);
37-
if (isKey && stringEquals(key, adaptString(variant.asString())))
37+
if (isKey && stringEquals(key, adaptString(VariantImpl::asString(
38+
it.data(), resources_))))
3839
return it;
3940
isKey = !isKey;
4041
}

src/ArduinoJson/Variant/VariantData.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,16 @@ class VariantImpl {
316316
}
317317

318318
JsonString asString() const {
319-
switch (type()) {
319+
if (!data_)
320+
return JsonString();
321+
return asString(data_, resources_);
322+
}
323+
324+
static JsonString asString(VariantData* data_, ResourceManager* resources_) {
325+
ARDUINOJSON_ASSERT(data_ != nullptr);
326+
ARDUINOJSON_ASSERT(resources_ != nullptr);
327+
328+
switch (data_->type) {
320329
case VariantType::TinyString:
321330
return JsonString(data_->content.asTinyString);
322331
case VariantType::LongString:

0 commit comments

Comments
 (0)