From e94089ca5690b09a39b4b4d68599df2a60d04501 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sat, 8 Nov 2014 21:16:47 +0100 Subject: [PATCH] Reduced size by 52 bytes by inlining createNode() --- include/ArduinoJson/Internals/List.hpp | 12 +++++++++--- src/Internals/List.cpp | 7 ------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/ArduinoJson/Internals/List.hpp b/include/ArduinoJson/Internals/List.hpp index eaf18df8..175aaeb8 100644 --- a/include/ArduinoJson/Internals/List.hpp +++ b/include/ArduinoJson/Internals/List.hpp @@ -6,9 +6,10 @@ #pragma once -#include "ListIterator.hpp" -#include "ListConstIterator.hpp" #include "../JsonBuffer.hpp" +#include "ListConstIterator.hpp" +#include "ListIterator.hpp" +#include "PlacementNew.hpp" namespace ArduinoJson { namespace Internals { @@ -48,7 +49,12 @@ class List { const_iterator end() const { return const_iterator(NULL); } protected: - node_type *createNode(); + node_type *createNode() { + if (!_buffer) return NULL; + void *ptr = _buffer->alloc(sizeof(node_type)); + return ptr ? new (ptr) node_type() : NULL; + } + void addNode(node_type *node); void removeNode(node_type *nodeToRemove); diff --git a/src/Internals/List.cpp b/src/Internals/List.cpp index 8265b0ee..b7d13667 100644 --- a/src/Internals/List.cpp +++ b/src/Internals/List.cpp @@ -20,13 +20,6 @@ int List::size() const { return nodeCount; } -template -typename List::node_type *List::createNode() { - if (!_buffer) return NULL; - void *ptr = _buffer->alloc(sizeof(node_type)); - return ptr ? new (ptr) node_type() : NULL; -} - template void List::addNode(node_type *nodeToAdd) { if (_firstNode) {