mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 10:17:39 +02:00
Remove SlotData
This commit is contained in:
@ -12,7 +12,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 6, "slot size");
|
static_assert(sizeof(ArduinoJson::detail::VariantData) == 6, "slot size");
|
||||||
|
|
||||||
void setup() {}
|
void setup() {}
|
||||||
void loop() {}
|
void loop() {}
|
||||||
|
@ -10,7 +10,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 8, "slot size");
|
static_assert(sizeof(VariantData) == 8, "slot size");
|
||||||
|
|
||||||
void setup() {}
|
void setup() {}
|
||||||
void loop() {}
|
void loop() {}
|
||||||
|
@ -10,7 +10,6 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 16,
|
static_assert(sizeof(ArduinoJson::detail::VariantData) == 16, "slot size");
|
||||||
"slot size");
|
|
||||||
|
|
||||||
int main() {}
|
int main() {}
|
||||||
|
@ -10,6 +10,6 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 8, "slot size");
|
static_assert(sizeof(ArduinoJson::detail::VariantData) == 8, "slot size");
|
||||||
|
|
||||||
int main() {}
|
int main() {}
|
||||||
|
@ -73,7 +73,7 @@ inline bool ArrayData::addValue(const T& value, ResourceManager* resources) {
|
|||||||
|
|
||||||
// Returns the size (in bytes) of an array with n elements.
|
// Returns the size (in bytes) of an array with n elements.
|
||||||
constexpr size_t sizeofArray(size_t n) {
|
constexpr size_t sizeofArray(size_t n) {
|
||||||
return n * ResourceManager::slotSize;
|
return n * sizeof(VariantData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||||
|
@ -18,11 +18,7 @@ class VariantData;
|
|||||||
class VariantWithId;
|
class VariantWithId;
|
||||||
|
|
||||||
class ResourceManager {
|
class ResourceManager {
|
||||||
using SlotData = VariantData; // TODO: remove SlotData?
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr static size_t slotSize = sizeof(SlotData);
|
|
||||||
|
|
||||||
ResourceManager(Allocator* allocator = DefaultAllocator::instance())
|
ResourceManager(Allocator* allocator = DefaultAllocator::instance())
|
||||||
: allocator_(allocator), overflowed_(false) {}
|
: allocator_(allocator), overflowed_(false) {}
|
||||||
|
|
||||||
@ -154,7 +150,7 @@ class ResourceManager {
|
|||||||
Allocator* allocator_;
|
Allocator* allocator_;
|
||||||
bool overflowed_;
|
bool overflowed_;
|
||||||
StringPool stringPool_;
|
StringPool stringPool_;
|
||||||
MemoryPoolList<SlotData> variantPools_;
|
MemoryPoolList<VariantData> variantPools_;
|
||||||
MemoryPoolList<const char*> staticStringsPools_;
|
MemoryPoolList<const char*> staticStringsPools_;
|
||||||
#if ARDUINOJSON_USE_8_BYTE_POOL
|
#if ARDUINOJSON_USE_8_BYTE_POOL
|
||||||
MemoryPoolList<EightByteValue> eightBytePools_;
|
MemoryPoolList<EightByteValue> eightBytePools_;
|
||||||
|
@ -21,9 +21,9 @@ inline Slot<VariantData> ResourceManager::allocVariant() {
|
|||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ResourceManager::freeVariant(Slot<VariantData> variant) {
|
inline void ResourceManager::freeVariant(Slot<VariantData> slot) {
|
||||||
variant->clear(this);
|
slot->clear(this);
|
||||||
variantPools_.freeSlot({alias_cast<SlotData*>(variant.ptr()), variant.id()});
|
variantPools_.freeSlot(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline VariantData* ResourceManager::getVariant(SlotId id) const {
|
inline VariantData* ResourceManager::getVariant(SlotId id) const {
|
||||||
|
@ -86,7 +86,7 @@ inline VariantData* ObjectData::addPair(VariantData** value,
|
|||||||
|
|
||||||
// Returns the size (in bytes) of an object with n members.
|
// Returns the size (in bytes) of an object with n members.
|
||||||
constexpr size_t sizeofObject(size_t n) {
|
constexpr size_t sizeofObject(size_t n) {
|
||||||
return 2 * n * ResourceManager::slotSize;
|
return 2 * n * sizeof(VariantData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||||
|
Reference in New Issue
Block a user